Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Programming Fundamentals

Boolean operators AND, OR and NOT

The common Boolean operators AND, OR and NOT

2.2.1 Programming Fundamentals

Practise exam questions

Programming Fundamentals — Note 6 of 6

== != <> <= >= < > '

What you need to know

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.

What to know

  • AND returns True only if BOTH conditions are True.
  • OR returns True if EITHER condition (or both) is True.
  • NOT reverses a Boolean value: NOT 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.
  • Boolean operators can be combined: e.g. if A AND (B OR C) → customer is 15+ AND has ticket OR has money.
  • These operators are essential for writing conditions in if statements and while loops.
  • Every comparison produces a Boolean: 5 == 5 is True, 5 != 2 is True, 5 < 2 is False, 5 <= 4 is False.
  • Python writes Boolean operators in lowercase (and, or, not). OCR Exam Reference Language writes them in uppercase (AND, OR, NOT).

Exam technique

  • Mistake:if room == "basic" or "premium" is WRONG. You must compare the variable each time: if room == "basic" or room == "premium".
  • Mistake:Checking for invalid input with OR can be wrong. e.g. if room != "basic" or room != "premium" is always True. Use AND instead: if room != "basic" and room != "premium".
  • Tip:Pay careful attention to AND vs OR. Check validity with AND (both conditions must hold), check invalidity with OR (either condition fails).
  • Mistake:Operator precedence — AND is evaluated BEFORE OR (like BIDMAS). 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).
  • Tip:== is a COMPARISON operator, + is ARITHMETIC, DIV is ARITHMETIC, > is COMPARISON. You may be asked to classify operators.

Code examples

Boolean and comparison operators
python
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")
Using and, or and not in conditions
python
# and: BOTH conditions must be True
age = int(input("Enter your age: "))
if age >= 13 and age <= 19:
    print("You are a teenager")

# or: AT LEAST ONE condition must be True
day = input("Enter the day: ")
if day == "Saturday" or day == "Sunday":
    print("It's the weekend!")

# not: reverses a Boolean value
logged_in = False
if not logged_in:
    print("Please log in first.")

Ready to test yourself?

Practise 2.2.1 questions
← Previous noteArithmetic operators2.2.1 Programming FundamentalsNext topic →Data types2.2.2 Data Types

Back to Programming Fundamentals

Revise another OCR GCSE topic: Data Types, Additional Programming Techniques

Programming Fundamentals

Note 6 of 6

  1. 1Variables, constants, operators, inputs, outputs and assignments
  2. 2Sequence
  3. 3Selection
  4. 4Iteration (count- and condition-controlled loops)
  5. 5Arithmetic operators
  6. 6Boolean operators AND, OR and NOT
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).