Boolean logic: AND, OR, NOT

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

Practise this lesson free (6 questions)

More tools

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.
ABA AND BA OR BNOT A
00001
01011
10010
11110

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.

Key words
Boolean
A data type with only two values: True or False.
AND
A Boolean operator that gives True (1) only when both inputs are True.
NOT
A Boolean operator that flips its input: True becomes False and False becomes True.
Truth table
A table showing the output of a logic gate or Boolean expression for every possible combination of inputs.
Output
Information sent out from a computer, for example to a screen, speaker or printer.
Input
Data put into a computer, for example from a keyboard, mouse, microphone or sensor.

All KS3 Computing key terms and definitions →

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. What is 0 AND 1?

    Show the answer

    Answer: 0

    AND gives 1 only if both inputs are 1.

  2. What is 0 OR 1?

    Show the answer

    Answer: 1

    OR gives 1 if at least one input is 1.

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.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Facts checked against the sources below, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

Related lessons