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?

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.

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.

The preparation-room door

For each situation, set the two inputs, predict whether the door unlocks (1) or stays locked (0), then test it.

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 validPIN correctDoor unlocks
000
010
100
111

Check your understanding

In how many of the four situations does the door unlock?
Show the answer

Answer: B. One: only when the card is valid and the PIN is correct.

The door unlocks only when both inputs are 1. If either input is 0, the output is 0.

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…”.

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:

ABQ
000
010
100
111

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?

Show what happens

Yes. Either reason is enough on its own, and having both reasons at once is certainly enough.

The emergency lights

Predict, then test, all four situations.

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 soundingSwitch pressedLights on
000
011
101
111

Check your understanding

Compare the lights with the door. Which statement describes the lights’ rule?
Show the answer

Answer: C. The output is 1 when at least one input is 1, including when both are.

This rule is called OR, and a gate that applies it is an OR gate. Its output is 0 only when both inputs are 0.

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?

Show what happens

When daylight = 1 the light is off (0); when daylight = 0 the light is on (1). The output is always the opposite of the input.

The security light

This gate has only one input. Predict, then test, both situations.

The rule and the complete table

This is a NOT gate. The output is the opposite of the input. Q = NOT A

DaylightLight on
01
10

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

A classroom fan is set to run when the window is NOT open. The input “window open” is 1. What is the fan’s output?
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

A games console downloads an update only if it is connected to the internet and the user has agreed to updates. Which gate describes the decision?
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

In the console example, which of these is the output?
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

Sam says: “The emergency lights use AND, because the alarm and the switch both control the lights.” What is wrong with Sam’s reasoning?
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.

  1. Say what the inputs mean. A = 1: the card is valid. B = 0: the PIN is wrong.
  2. Say what the rule needs. The door uses AND, so it unlocks only if every input is 1.
  3. Compare. B is 0, so not every input is 1.
  4. 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).

The merit rule: Q = A OR B
A: homework on timeB: helped someoneQ
00
01
10
11

    Show the completed table
    A: homework on timeB: helped someoneQ
    000
    011
    101
    111

    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.

    The closed sign: Q = NOT A
    A: library openQ
    0
    1

      Show the completed table
      A: library openQ
      01
      10

      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

      A school’s heating comes on when the building is in use and the temperature is below 18 °C. A pupil wants to model it with one gate. Which gate, and why?
      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.