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.
Three operators
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 | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 |
Boolean logic in Python
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).
A = 1, B = 0. Work out NOT (A AND B).
- A AND B = 1 AND 0 = 0.
- NOT 0 = 1.
Answer: 1
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.
- 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.
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
What is 0 AND 1?
Show the answer
Answer: 0
AND gives 1 only if both inputs are 1.
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.
Facts checked against the sources below, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.