O Level Computer Science (2210)

Boolean logic

Logic gates and truth tables

The six logic gates, NOT, AND, OR, NAND, NOR, and XOR, with their symbols and truth tables.

Examples use Cambridge pseudocode for the 2026–2028 syllabus.

Gates make decisions with 1s and 0s

A logic gate is an electronic component that takes one or two binary inputs and produces one binary output. 1 means on (TRUE), 0 means off (FALSE). Every calculation a CPU does is built from millions of these gates.

A truth table lists every possible combination of inputs and the output for each. With 2 inputs there are 4 rows; with 3 inputs there are 8.

Try every gate

Pick a gate, then click the inputs (or a row of the truth table). Highlighted wires carry a 1.

Logic gate explorerInteractive
A=0NOT1
Truth table
AOut
01
10
Click an input or a table row.

The rules in words

GateOutput is 1 when...Expression
NOTthe input is 0 (it flips the input)X = NOT A
ANDboth inputs are 1X = A AND B
ORat least one input is 1X = A OR B
NANDNOT AND: the inputs are not both 1X = A NAND B
NORNOT OR: neither input is 1X = A NOR B
XORthe inputs are differentX = A XOR B

Exam tip. A small circle (bubble) on a gate's output means NOT. That is the only difference between AND and NAND, or OR and NOR.

Check yourself

Which gate outputs 0 only when both inputs are 1?Show answer

NAND.

What is 1 XOR 1?Show answer

0: the inputs are the same.

How many rows does a truth table with 3 inputs need?Show answer

2³ = 8 rows.

References used to build these lessons

We used these official documents as references when building this course's lessons. They are the sources for the syllabus structure and course requirements.

Cambridge International · 2210 · Exams 2026–2028