Python Fundamentals · Python Basics
True and False, comparison operators, and/or/not, chained comparisons, and which values count as false.
age = 17
has_ticket = True
is_adult = age >= 18
can_enter = is_adult or has_ticket
needs_help = not has_ticket and age < 12
in_range = 13 <= age <= 19 # comparisons can be chained
empty_is_false = bool("") # empty things count as False
zero_is_false = bool(0)
print(is_adult, can_enter, needs_help, in_range, empty_is_false, zero_is_false)age is created with the value 17.has_ticket is created with the value true.or is True if either side is: False or True gives True.not has_ticket is False, so the whole and is False without even checking the age.