Knowledge organisersProgramming Fundamentals
== != <> <= >= < > '
Boolean operators (AND, OR, NOT) work with Boolean values (True/False) and are used in conditions to control program flow. Comparison operators (==, !=, <, >, <=, >=) compare values and return True or False. These are combined in selection and iteration statements to create complex conditions.
True only if BOTH conditions are True.True if EITHER condition (or both) is True.True = False, NOT False = True.== checks if two values are equal; != checks if they are not equal.< less than, > greater than, <= less than or equal to, >= greater than or equal to. Use >= not ≥ in code.if A AND (B OR C) → customer is 15+ AND has ticket OR has money.if room == "basic" or "premium" is WRONG. You must compare the variable each time: if room == "basic" or room == "premium".if room != "basic" or room != "premium" is always True. Use AND instead: if room != "basic" and room != "premium".if SystemArmed AND DoorActive OR WindowActive will sound the alarm when the window is active even if the system is NOT armed! Fix with BRACKETS: if SystemArmed AND (DoorActive OR WindowActive).== is a COMPARISON operator, + is ARITHMETIC, DIV is ARITHMETIC, > is COMPARISON. You may be asked to classify operators.age = 20
has_ticket = True
# AND: both must be True
if age >= 18 and has_ticket:
print("Entry allowed")
# OR: at least one must be True
if age < 12 or age > 65:
print("Discount applies")
# NOT: reverses the value
logged_in = False
if not logged_in:
print("Please log in")