Florence's Computing · Logic · Lesson 4
1847

How a circuit
makes up its mind.

Underneath every decision a computer makes are tiny gates that answer one kind of question — true or false. String a few together and a machine of switches can start to think.
For Florence,
flipping the inputs.
Florence's Computing · Lesson 4
Two values

A circuit only knows true and false.

You've met binary already — a computer is built from millions of tiny switches, each one on or off, which we write as 1 and 0. There is another way to read those same two states, and it is the key to this whole lesson. 1 can mean true; 0 can mean false. On is true, off is false. Suddenly the machine isn't just storing numbers — it's holding answers to yes-or-no questions.

Once a circuit can hold a true or a false, the next question is: can it combine them? If this is true and that is true, is the whole thing true? If either one is true, is it enough? Answering those questions — true and false, combined by simple rules — is called logic, and the tiny circuits that do it are called logic gates. A gate takes one or two inputs (each true or false) and gives back a single output (true or false), by a fixed rule. That is all a gate is.

1 and 0, true and false

Through this lesson, 1 = true = on and 0 = false = off. They are the same two states you met in binary, just read as answers rather than numbers. A logic gate is a circuit that takes true/false in and gives one true/false out.

A detail worth knowing
30–45 seconds · MF 1
Cool fact

This lesson builds directly on How computers represent data, where you met bits as 1s and 0s. The very same bits are at work here — only now we read 1 as true and 0 as false, and ask what happens when we combine them.

Florence's Computing · Lesson 4
The simplest gate

NOT — the gate that flips.

The simplest gate of all takes a single input and turns it into its opposite. If you put in true, it gives back false; put in false, it gives back true. It is called the NOT gate, and it does exactly what the word says: it gives you not what you put in. Think of a switch on a landing that reverses the light — NOT is that idea, in a circuit.

Every gate can be summed up in a small grid called a truth table. It lists every possible input and the output beside it. Because each input is only ever true or false, the table is always short. Here is the whole of NOT:

input output NOT
NOT
InOut
01
10
The NOT gate symbol — a triangle with a little circle on its nose. The circle is the "flip". Its truth table has just two rows. Original schematic
Reading a truth table

Read each row left to right: "if the input is this, the output is that." The output column (here on the right, shaded) is the gate's answer. NOT simply swaps 0 and 1 — true becomes false, false becomes true.

Florence's Computing · Lesson 4
Watch

Logic gates, seen at work.

You've met true, false, and your first gate. This short film shows the gates as real little circuits, switching as their inputs change. Watch for the moment an AND gate only lights up when both its inputs are on — the idea you're about to meet on the next page.

Code.org — “How computers calculate: the ALU” (logic gates at work).YouTube
Florence's Computing · Lesson 4
Two inputs now

AND, and OR — the two that take two.

The next two gates each take two inputs. The AND gate is strict: its output is true only when both inputs are true. Think of a microwave that runs only when the door is shut and the start button is pressed — both, or nothing. The OR gate is generous: its output is true when either input is true (or both). Think of a light with two switches — flip either one and the light comes on.

AND

AB out
AND — true only if both
ABOut
000
010
100
111

OR

AB out
OR — true if either
ABOut
000
011
101
111

There is a third two-input gate worth knowing by name: XOR, short for "exclusive OR". It is like OR but fussier — it is true when the inputs are different, and false when they are the same. So two trues make a false, which surprises people. XOR is the gate behind "one or the other, but not both" — a fair coin toss between two choices.

XOR — true only if different
ABOut
000
011
101
110
Cool fact

XOR has a quiet superpower: add two single bits with it and you get the right answer for the last digit, every time (0 xor 0 = 0, 1 xor 0 = 1, 1 xor 1 = 0, carry the one). That's why XOR sits at the heart of the circuit that does addition — the part of a computer that actually adds up is built largely from XOR and AND gates.

Florence's Computing · Lesson 4
Stringing them together

Combining gates to make a decision.

One gate answers one small question. The magic happens when you wire the output of one gate into the input of the next — then a circuit can answer a question that no single gate could. Here is a real example. An alarm should sound when a window is open AND the system is armed — but not if you've pressed the "I'm home" button. You can build that from gates you already know:

window open system armed “I'm home” AND NOT AND alarm sounds
Window open AND system armed — then AND-ed with NOT "I'm home". The alarm sounds only when all three conditions line up. Original schematic

That is genuinely how a computer "thinks". There is no cleverness hidden anywhere — only millions of these gates, wired together, each answering its one true-or-false question, passing the answer along. Out of that, and nothing more, comes everything: arithmetic, memory, decisions, the whole machine. A circuit doesn't understand. It just follows the rules of true and false, very fast, very many times.

A detail worth knowing
30–45 seconds · MF 1

Tap each card — the rule each gate follows:

NOT One input. Flips it — true becomes false, false becomes true.
AND True only when both inputs are true.
OR True when either input is true (or both).
XOR True only when the inputs are different.
Try it

Flip the inputs, watch the gate decide.

Pick a gate, then flip its inputs between 0 and 1. The lamp shows the gate's answer, and the row underneath fills in the matching line of the truth table. (NOT has only one input, so its second switch quietly steps aside.)

A
B
AND
0
output is false
A = 0, B = 0 → 0
AND is true only when both inputs are true. Flip both to 1 to light the lamp.
Florence's Computing · Lesson 4
Question 1 · circle the correct answer

True, false, 1, 0.

In logic, what do 1 and 0 usually stand for?
Question 2 · circle the correct answer

The NOT gate.

You put true (1) into a NOT gate. What comes out?
Question 3 · circle the correct answer

When is AND true?

An AND gate has inputs A and B. In which case is its output true?
Question 4 · circle the correct answer

AND or OR?

A light should come on if either of two switches is flipped. Which gate matches that rule?
Florence's Computing · Lesson 4
Question 5 · fill the truth table

Complete the OR gate.

Here is the OR gate's truth table with the last output missing. OR is true when either input is true. What goes in the empty cell — a 0 or a 1?
A=0 B=0 → 0  ·  A=0 B=1 → 1  ·  A=1 B=0 → 1  ·  A=1 B=1 → ?
A=1 B=1 →
For OR, the only row that gives 0 is when both inputs are 0.
Question 6 · type your answer

Work the XOR gate.

XOR is true only when its two inputs are different. You feed it A = 1 and B = 1. What is the output — 0 or 1?
output =
Same inputs → 0. Different inputs → 1. Here both are 1.
Question 7 · circle the correct answer

Why combine gates?

What does wiring the output of one gate into the input of another let you do?
Question 8 · circle the correct answer

How a circuit "thinks".

A computer makes decisions using logic gates. Which statement is the most accurate?
Florence's Computing · Lesson 4
Question 9 · in your own words

Explain the difference between AND and OR.

Imagine explaining it to a friend who has never seen a logic gate. Use an everyday example if it helps — two switches, a door and a button, anything. Try to make clear when each gate gives true. Three or four sentences is plenty. Try to use, in your own way, the words AND, OR, true and both.

0 words
reading what you wrote…

A few thoughts on your explanation, Florence

strong You caught the heart of it — AND needs both, OR needs only one. That single word "both" is the whole difference, and you leaned on it. The everyday example you reached for makes the rule feel obvious rather than abstract, which is exactly what a good explanation does.

try this One sentence describes OR as "either one", which is right, but it's worth adding the small extra: OR is also true when both are true. That "or both" is the part people forget, and naming it shows you've read the whole truth table, not just the easy rows.

to add You could close with one line on why this matters: that real circuits are built by wiring these simple rules together. That turns two definitions into the start of an idea about how a computer thinks.

Watch together

Films and series on the logic underneath.

Sit down with Dad for any of these. They show how true and false, wired together, became the machine on your desk. Heavier titles flagged for a chat first.

Documentary · BBC · 2008 · PG
The Secret Life of the Machine — Tim Hunkin
The computer episode builds a machine up from switches and simple logic, by hand, exactly the way this lesson does. Gentle, funny and genuinely clear.
Documentary · 1992 · U
The Machine That Changed the World
A calm five-part history of the computer, from the first logic circuits to the modern machine. Full of the people who worked out how to make switches think.
Documentary · BBC · 2015 · PG
Calculating Ada: The Countess of Computing
Ada Lovelace saw, long before any circuit existed, that a machine following strict rules could handle any kind of logic. The idea begins with her.
Drama · 2014 · 12A
The Imitation Game
Alan Turing and the wartime machines that turned logic loose on coded messages — the ancestors of the gates in this lesson. Heavier in places — chat afterwards.
Documentary · 2013 · PG
The Code — Marcus du Sautoy
A mathematician finds the hidden logic and patterns running through the world. Not about gates directly, but about the same love of rules underneath things.
Florence's Computing · Lesson 4
Glossary

The words from today.

Logic gate
A tiny circuit that takes one or two true/false inputs and gives one true/false output, by a fixed rule.
Truth table
A short table listing every possible input to a gate and the output for each.
NOT
A one-input gate that flips its input: true becomes false, false becomes true.
AND / OR
AND is true only when both inputs are true; OR is true when either input (or both) is true.
XOR
"Exclusive OR" — true only when the two inputs are different. It sits at the heart of addition.
Boolean logic
The maths of true and false, named after George Boole. The rules every logic gate follows.
Watch

Worth watching.

Two short films to watch alongside today's lesson — each shows you something the words and pictures can't.

See the three basic gates — AND, OR, NOT — drawn and explained clearly.Computerphile · YouTube
Why just two values, true and false, are enough to power everything digital.Khan Academy · YouTube
End of lesson four

You've seen how a circuit makes up its mind.

You learned that a circuit reads 1 and 0 as true and false. You met the gates: NOT flips, AND needs both, OR needs either, and XOR wants them different. You read their truth tables, combined gates to make a real decision, and saw that a computer "thinks" only by answering millions of true-or-false questions, very fast. There is no magic in there — just logic. Florence, this is computing.

F.M. · Computing · Logic · Lesson 4
Cool fact

You can build every other gate out of just one kind, called NAND (an AND with a NOT on the end). Wire enough NANDs together in the right way and you can make NOT, AND, OR, XOR — and from those, a whole computer. Engineers call NAND "universal" for exactly this reason: one humble gate is, in principle, enough for everything.

Images · All diagrams in this lesson — the NOT, AND and OR gate symbols, the combined alarm circuit and the gate truth tables — are original SVG line-art, drawn for this lesson. Use them freely. The cover is a CSS-drawn logic motif, no photograph.
Videos are embedded from Code.org's official YouTube channel.
Film recommendations are factual reference only — see each title's own copyright owner.