Logic gates and truth tables
About this lesson: Logic gates and truth tables
In short
A logic gate takes binary inputs and gives one binary output. Choose a gate, then tap A and B to change the inputs.

What you'll explore
- NOT, AND, OR: The three basic gates
- A logic gate takes binary inputs and gives one binary output. Choose a gate, then tap A and B to change the inputs.
- NAND, NOR, XOR: Three more gates
- NAND and NOR are AND and OR with the output flipped. XOR gives 1 when the inputs are different.
- Logic in programs: Both must be TRUE
- The same logic appears in IF statements: a ride needs height ≥ 130 AND age ≥ 8. Change the inputs.
- Logic in devices: A light level decides
- A night light switches on when it is dark AND movement is detected. Sensors give the inputs, logic decides the output.
- Check yourself: XOR
- An XOR gate has inputs A = 1 and B = 1.
Also in this lesson
- Step by step
- Six gates
- Watch out for these
- More than the lesson
- Stretch your brain
- Try it yourself
Words to know
- Logic gate
- A circuit that gives a binary output from binary inputs.
- Truth table
- A table listing every input combination and the output.
- Boolean
- A value that is TRUE (1) or FALSE (0).
- Inverter
- Another name for a NOT gate.
- XOR
- Exclusive OR: one or the other, not both.
Sources
- Raspberry Pi Foundation, Isaac Computer Science: logic gates
- George Boole (1854), An Investigation of the Laws of Thought
- Claude Shannon (1937), A Symbolic Analysis of Relay and Switching Circuits
- BBC Bitesize, GCSE Computer Science: logic
← Asking questions with SQL · Logic circuits and expressions →