
age = 18
if age >= 18:
print("Adult")
elif age >= 13:
print("Teenager")
else:
print("Child")Comparison operators:
== # equal != # not equal > # greater than < # less than >= # greater or equal <= # less or equal
Logical operators:
if age >= 18 and age < 65:
print("Working age")
if name == "Alice" or name == "Bob":
print("Known user")
if not is_banned:
print("Welcome")Ternary (one-liner):
status = "adult" if age >= 18 else "minor"
Truthy/Falsy: Empty string, 0, None, empty list/dict/set are all False. Everything else is True. This enables: if my_list: instead of if len(my_list) > 0:
Reference:
TaskLoco™ — The Sticky Note GOAT