if-else
if condition: do this else: do this
if height > 120:
print('longer than 120')
elif second_condition:
print('bla")
else:
print('shorter than 120')
Comparison operators
| Operator | Meaning |
|---|---|
| > | Bigger than |
| < | Smaller than |
| >= | Bigger than or equal to |
| ⇐ | Smaller than or equal to |
| == | Equal to |
| != | Not equal to |
Multiple Conditions
If you have multiple conditions that are independent, you should write multiple separate if statements
- You don’t have to write an else statement
Logical Operators
and
or
not
Just reverses the operation. If false → true, if true → false