Logical Operators
# All the following code evaluates to True
1 == 1 # Equal to
'Chloe' == 'Chloe' # Works for strings as well
2.001 != 2 # Not equal to
'Chloe' != 'chloe' # Case matters, these aren't equal strings
1 > 0 # Greater than
3 < 5 # Less than
15 >= 15 # Greater than or equal to
# The above is equivalent to (15 > 15 or 15 == 15 )
amount_of_apples = 50
a <= 1400 # Less than or equal toExercises
energy_level = 3 low_energy = energy_level < 5 likes_coffee = True low_energy and likes_coffee
Last updated