Open the app
  1. Home
  2. Lessons
  3. KS3 Computing
  4. Boolean logic: AND, OR, NOT

Boolean logic: AND, OR, NOT

🎬 The doodle video for this lesson is coming soon. Subscribe on YouTube to see it first.

Boolean logic works with only two values: True and False (or 1 and 0). It is how programs and circuits make decisions.

Three operators

AND is True only if both inputs are True.
OR is True if at least one input is True.
NOT flips the input: NOT True = False.
They are named after George Boole, a 19th-century mathematician.

Truth tables

A truth table shows the output for every possible input. 1 = True, 0 = False.

Boolean logic in Python

Python uses and, or and not.
age = 12
print(age > 10 and age < 13)
prints True, because both parts are True.
A cinema rule: allowed in if (age >= 12) or (with_adult == True).
Worked example

A = 1, B = 0. Work out NOT (A AND B).

  1. A AND B = 1 AND 0 = 0.
  2. NOT 0 = 1.

Answer: 1

Key idea

AND needs both inputs true, OR needs at least one, NOT flips the value. A truth table lists the output for every combination of inputs.

The interactive lesson includes the diagrams for this topic.

Check you have got it

Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.