x = 0 y = 5 if x < y: # Truthy print("yes") if y < x: # Falsy print("yes") if x: # Falsy print("yes") if y: # Truthy print("yes") if x or y: # Truthy print("yes") if x and y: # Falsy print("yes") if "aul" in "grault": # Truthy print("yes") if "quux" in ["foo", "bar", "baz"]: # Falsy print("yes") x = 20 if x < 50: print("(first suite)") print("x is small") else: print("(second suite)") print("x is large") name = "Joe" if name == "Fred": print("Hello Fred") elif name == "Xander": print("Hello Xander") elif name == "Joe": print("Hello Joe") elif name == "Arnold": print("Hello Arnold") else: print("I don't know who you are!") if "f" in "foo": print("1") print("2") print("3") if "z" in "foo": print("1") print("2") print("3") x = 2 if x == 1: print("foo") print("bar") print("baz") elif x == 2: print("qux") print("quux") else: print("corge") print("grault") x = 3 if x == 1: print("foo") print("bar") print("baz") elif x == 2: print("qux") print("quux") else: print("corge") print("grault") age = 21 if age >= 18: print("You're a legal adult") age = 16 if age >= 18: print("You're a legal adult") else: print("You're NOT an adult") age = 18 if age > 18: print("You're over 18 years old") elif age == 18: print("You're exactly 18 years old") age = 45 gender = "M" if age < 18: if gender == "M": print("son") else: print("daughter") elif age >= 18 and age < 65: if gender == "M": print("father") else: print("mother") else: if gender == "M": print("grandfather") else: print("grandmother") raining = False print("Let's go to the", "beach" if not raining else "library") raining = True print("Let's go to the", "beach" if not raining else "library") age = 12 s = "minor" if age < 21 else "adult" s "yes" if ("qux" in ["foo", "bar", "baz"]) else "no" a = 2 b = 4 if a > b: m = a else: m = b # equivalente m = a if a > b else b x = y = 40 z = 1 + x if x > y else y + 2 z z = (1 + x) if x > y else (y + 2) z x = y = 40 z = 1 + (x if x > y else y) + 2 z s = ( "foo" if (x == 1) else "bar" if (x == 2) else "baz" if (x == 3) else "qux" if (x == 4) else "quux" ) print(s) a = b = c = d = 1 if a == b == c == d == 1: print("Si") else: print("No") a = b = c = d = 2 if a == b == c == d == 1: print("Si") else: print("No")