True, False, and comparisons
A program that does the same thing on every run is a calculator. To react to its input it needs decisions, and decisions start with values that are True or False. Comparisons produce them:
| Expression | Meaning | Example | Result |
|---|---|---|---|
== | Equal to | 3 == 3.0 | True |
!= | Not equal to | 5 != 5 | False |
< > | Less than, greater than | "a" < "b" | True |
<= >= | At most, at least | 10 >= 10 | True |
Combine them with and, or and not:
age = 20
has_ticket = False
print(age >= 18 and has_ticket) # False: both must be True
print(age >= 18 or has_ticket) # True: one is enough
print(not has_ticket) # True
Strings compare alphabetically by character code, which is why "a" < "b" is True. Note that 3 == 3.0 is also True: an int and a float with the same value compare equal.

