Study Guide
Introduction to Logic Gates
How a computer makes a decision from yes-or-no information: inputs and outputs, every combination of two inputs, and the AND, OR and NOT gates, discovered by testing everyday rules before they are named.
Lesson 2.1 Boolean Logic
For: Complete beginners: Key Stage 3 (about ages 11 to 14), or the start of a Cambridge IGCSE Computer Science course
Stage: Think
A door that decides
A school’s science preparation room keeps chemicals locked away. Its door has a card reader and a keypad: a member of staff taps their staff card, then types a four-digit PIN. The school is fictional, but doors like this are common.
Think it through
A teacher taps a valid staff card, but types the wrong PIN. What should the door do, and why?
- Hint 1: What is the door trying to protect?
- Hint 2: Imagine a pupil finds a teacher’s lost card. Should that be enough?
Show what happens
It should stay locked. The door needs both checks to pass. If a correct card were enough on its own, anyone who found a lost card could open the room.
Stage: Discover
Every possible situation
The door only ever looks at two things: is the card valid, and is the PIN correct? Each answer is yes or no.
Think it through
How many different situations can the door be in? Write each one down.
- Hint 1: Start with the card valid. What could the PIN be?
- Hint 2: Now do the same with the card not valid.
Show what happens
Four situations: card valid and PIN correct; card valid and PIN wrong; card not valid and PIN correct; card not valid and PIN wrong.
Each piece of information the door uses is an input: here, “card valid” and “PIN correct”. What the door decides, whether to unlock, is its output.
A computer stores yes-or-no information as 1 for yes (true) and 0 for no (false). So “card valid” is 1 or 0, “PIN correct” is 1 or 0, and “door unlocks” is 1 or 0. Working with values that can only be true or false is called Boolean logic, after the mathematician George Boole.
Stage: Experiment
Test the door’s rule
Below is the door’s decision as a computer would make it. You do not know its rule yet: find it by testing.
For each situation, set the two inputs, predict whether the door unlocks (1) or stays locked (0), then test it.
Set the inputs
Predict the output (Door unlocks): 0 or 1?
Test it
Door unlocks:
| Card valid | PIN correct | Door unlocks |
|---|---|---|
| 0 | 0 | ? |
| 0 | 1 | ? |
| 1 | 0 | ? |
| 1 | 1 | ? |
Challenge: Find every situation in which the door unlocks.
0 of 4 combinations tried.
The rule and the complete table
This is an AND gate. The output is 1 only when both inputs are 1. Q = A AND B
| Card valid | PIN correct | Door unlocks |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Stage: Explain
Naming the pattern: AND
Think it through
Before reading on, write the door’s rule as one sentence that starts “The door unlocks only when…”.
- Hint 1: How many of the inputs have to be 1?
Show what happens
“The door unlocks only when the card is valid and the PIN is correct.”
A rule where the output is 1 only when every input is 1 is called AND. A tiny electronic circuit that applies a fixed rule like this to its inputs is a logic gate; one that applies the AND rule is an AND gate. A computer’s processor is built from vast numbers of gates like this, each made from microscopic switches called transistors.
The four situations you tested, written as a table, are the AND gate’s truth table: every combination of inputs, with the output for each. Inputs are usually called A and B, and the output Q:
| A | B | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The input rows always go 00, 01, 10, 11, so every combination appears once and two tables can be compared row by row.
Go deeper Why 00, 01, 10, 11?
Those four rows are the numbers 0, 1, 2 and 3 written in binary, the number system computers use, which has only the digits 0 and 1. Counting in binary is a reliable way to list every combination without missing one. The lesson How Computers Count in Binary explains it fully, but you do not need it here.
Stage: Predict
A different kind of rule
The corridor outside the same room has emergency lights. They come on if the fire alarm is sounding, or if someone presses the manual emergency switch.
Think it through
The fire alarm is sounding and someone has also pressed the switch. Do the lights come on?
- Hint 1: Would it make sense for pressing the switch to turn the lights off during a fire?
Show what happens
Yes. Either reason is enough on its own, and having both reasons at once is certainly enough.
Predict, then test, all four situations.
Set the inputs
Predict the output (Lights on): 0 or 1?
Test it
Lights on:
| Alarm sounding | Switch pressed | Lights on |
|---|---|---|
| 0 | 0 | ? |
| 0 | 1 | ? |
| 1 | 0 | ? |
| 1 | 1 | ? |
Challenge: Is there any situation in which the lights stay off?
0 of 4 combinations tried.
The rule and the complete table
This is an OR gate. The output is 1 when at least one input is 1. Q = A OR B
| Alarm sounding | Switch pressed | Lights on |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Check your understanding
In everyday speech “or” often means one or the other but not both: “tea or coffee?”. In logic, OR always includes both: if either input is 1, or both are, the output is 1. The one-or-the-other-but-not-both rule exists too, with its own name, in the next lesson.
Stage: Discover
Turning a value round: NOT
A security light outside the school’s main entrance switches itself on when it gets dark. It has one sensor, which reports whether it is daylight.
Think it through
The sensor reports daylight = 1. Should the light be on? And when daylight = 0?
- Hint 1: The light is for when people cannot see.
This gate has only one input. Predict, then test, both situations.
Set the inputs
Predict the output (Light on): 0 or 1?
Test it
Light on:
| Daylight | Light on |
|---|---|
| 0 | ? |
| 1 | ? |
0 of 2 combinations tried.
The rule and the complete table
This is a NOT gate. The output is the opposite of the input. Q = NOT A
| Daylight | Light on |
|---|---|
| 0 | 1 |
| 1 | 0 |
A rule that turns its input round is called NOT, and a gate that applies it is a NOT gate. Unlike AND and OR, a NOT gate has exactly one input.
Check your understanding
Show the answer
Answer: A. 0: the window is open, so the fan does not run.
The output of NOT is the opposite of its input: input 1 gives output 0.
Stage: Apply
Which gate fits?
Apply it
Show the answer
Answer: B. AND, because both conditions must be true before it downloads.
Two inputs that must both be 1: that is AND.
Check your understanding
Show the answer
Answer: C. Whether the update downloads.
Inputs are the facts that go in; the output is the decision that comes out.
Apply it
Show the answer
Answer: A. Two inputs can belong to any gate; with AND, the switch alone would not turn the lights on.
The number of inputs does not decide the gate: the rule does. Test a row to tell AND from OR.
Stage: Experiment
Complete the truth tables yourself
Now use what you have found, without the tester. First, see how one row is worked out by reasoning rather than remembered.
Take the row A = 1, B = 0 of the door’s table.
- Say what the inputs mean. A = 1: the card is valid. B = 0: the PIN is wrong.
- Say what the rule needs. The door uses AND, so it unlocks only if every input is 1.
- Compare. B is 0, so not every input is 1.
- Write the output, with the reason. Q = 0: the door stays locked, because AND needs both inputs to be 1.
Any row of any table can be worked out the same way, so a table never needs to be memorised.
A school gives a merit (Q) when a pupil hands in homework on time (A) or helps another pupil (B).
| A: homework on time | B: helped someone | Q |
|---|---|---|
| 0 | 0 | |
| 0 | 1 | |
| 1 | 0 | |
| 1 | 1 |
- Read each row: is at least one input 1?
Show the completed table
| A: homework on time | B: helped someone | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
A library door has a sensor that reports whether the library is open (A). A sign saying “Closed” lights up (Q) when the library is NOT open.
| A: library open | Q |
|---|---|
| 0 | |
| 1 |
Show the completed table
| A: library open | Q |
|---|---|
| 0 | 1 |
| 1 | 0 |
Think it through
Choose one row of the merit table and explain, in a sentence, why its output is what it is.
Show a model answer
For example: “In the row A = 1, B = 0 the pupil handed homework in on time but did not help anyone; OR needs only one input to be 1, so the merit is given (Q = 1).”
Stage: Consolidate
Show what you know
Think it through
Explain the difference between AND and OR to someone who missed this lesson, using an example of your own (not the door or the lights).
Show a model answer
A good answer gives a situation for each and says which input combination tells them apart. For example: “A bike shed opens with a key AND a code, so a key alone is not enough. A phone rings if a call OR a video call comes in, so either one is enough. The difference shows when only one input is 1: AND gives 0, OR gives 1.”
Apply it
Show the answer
Answer: C. AND: the heating needs both “in use” and “below 18 °C” to be true.
Two conditions that must both be true: AND.
Think it through
Which part of today’s lesson are you least sure about? Write one question you would ask your teacher.
Show a model answer
There is no wrong answer. Two questions worth asking: “how do I tell AND from OR?” (test the row where only one input is 1) and “how many rows does a table need?” (four for two inputs; the third lesson shows why eight for three).
- An input is information a system uses; the output is its decision. A computer records each as 1 (true) or 0 (false): Boolean logic.
- A truth table lists every combination of inputs, in the order 00, 01, 10, 11, with the output for each.
- AND gives 1 only when both inputs are 1. OR gives 1 when at least one input is 1. NOT has one input and turns it round.
- The number of inputs does not decide the gate: test the row where only one input is 1.
- This lesson describes gates in words and tables only. Each gate also has a standard symbol for drawing circuits: the symbols are introduced in Lesson 2, More Logic Gates, with three more gates.
Sources and scope
- What this lesson is. The first of four draft lessons on Boolean logic, written for this site. The site owner approved its teaching editorially on 7 November 2026; it is not yet published. It replaces the first half of the earlier single draft, Logic Gates and Truth Tables (3 November 2026), after the review of 4 November 2026. Its curriculum links are provisional: the wording of each linked specification point has been checked against the published specification, but no link has yet been verified by the site owner. The links show where the lesson may help with a course; they do not imply that any examination board has reviewed or endorsed it.
- Original material. The preparation-room door, the corridor’s emergency lights, the security light, the classroom fan, the console, the merit rule, the library sign, the heating and Sam’s claim are fictional examples written for this lesson.
- Simplified on purpose. Real door controllers, lighting and heating systems include more conditions (time locks, overrides, timers); each example keeps only the conditions the lesson needs.
A logic gate whose output is 1 only when both of its inputs are 1.
Reasoning with values that are either true or false (1 or 0), combined with operations such as AND, OR and NOT.
A closed path that electricity flows around, made of connected components. A logic gate is a very small circuit, made of transistors.
A piece of information that goes into a system for it to use, such as whether a card is valid. In a logic gate each input is 0 or 1.
A small electronic circuit that takes one or more binary inputs and produces one binary output according to a fixed rule. A NOT gate has exactly one input.
A logic gate with one input, whose output is the opposite of its input: 1 becomes 0 and 0 becomes 1.
A logic gate whose output is 1 when at least one of its inputs is 1, including when both are.
What a system produces from its inputs, such as whether a door unlocks. A logic gate has one output, 0 or 1.
A table listing every possible combination of a logic gate’s or circuit’s inputs, with the output for each.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.