Knowledge organisersBoolean Expressions
Use AND OR NOT.
Logical operators combine Boolean expressions. and requires both to be True, or requires at least one, and not flips True to False or vice versa.
and: both must be True → True and True = Trueor: at least one True → False or True = Truenot: reverses the value → not True = Falseage = 16
has_id = True
if age >= 18 and has_id:
print("Entry allowed")
if age < 13 or age > 65:
print("Discount applies")
if not has_id:
print("ID required")