Docs

Topic 10 · Boolean logic

Logic gates and truth tables

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

Lesson 1 of 2Syllabus 10.1, 10.2updated October 31, 2026

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.

Key terms

Logic gate
A component that performs a Boolean operation on binary inputs.
Truth table
A table showing the output for every combination of inputs.
XOR
Exclusive OR: outputs 1 only when the inputs are different.

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.