Boolean Logic (GCSE & IGCSE Computer Science): Revision Notes and Worksheets
GCSE and IGCSE Computer Science Boolean logic: AND, OR, NOT, NAND, NOR and XOR gates, truth tables, logic circuits, logic expressions and problem statements.

Every decision a computer makes comes down to inputs that are on or off, 1 or 0, combined by logic gates. This guide covers GCSE and IGCSE Boolean logic: the logic gates and their symbols, truth tables for single gates and whole circuits, reading logic circuits with more than one gate, writing and drawing logic expressions, and turning a problem statement into a logic circuit. Each part has a worked example and a worksheet for your exam board.
OCR J277 students: skip Q2, and the points marked IGCSE only. Cambridge IGCSE 0478 students: you need every part, but skip the points marked GCSE only. All the scenarios in this post are made up.
What does Boolean logic cover for OCR and Cambridge?
Boolean logic is about values that can only be true (1) or false (0), and the logic gates that combine them. OCR J277 covers it in one sub-topic, 2.4.1, using AND, OR and NOT only. Cambridge IGCSE 0478 covers it in topic 10 with six gates: NOT, AND, OR, NAND, NOR and XOR, and asks you to move between problem statements, logic circuits, logic expressions and truth tables in every direction. Both are on Paper 2. The table below is based on the OCR J277 specification (version 3.1) and the Cambridge IGCSE 0478 syllabus for 2026-2028, as checked in November 2026.
Part | Topic | OCR J277 | Cambridge 0478 |
|---|---|---|---|
Q1 | Logic gates: AND, OR and NOT (both boards) | 2.4.1 | 10.1, 10.2 |
Q2 | NAND, NOR and XOR gates (IGCSE only) | not on specification | 10.1, 10.2 |
Q3 | Truth tables for single gates (both boards) | 2.4.1 | 10.2 |
Q4 | Reading logic circuits with more than one gate (both boards) | 2.4.1 | 10.3(b), 10.3(c) |
Q5 | Completing a truth table for a logic circuit (both boards) | 2.4.1 | 10.3(b) |
Q6 | Logic expressions: writing them and drawing them (both boards; from a truth table IGCSE only) | 2.4.1 | 10.3(a), 10.3(c) |
Q7 | From problem statement to logic circuit (both boards) | 2.4.1 | 10.3(a), 10.3(c) |
Q1: What do the AND, OR and NOT logic gates do?
Both boards. A logic gate takes one or more binary inputs (1 means true or on, 0 means false or off) and produces one binary output.
AND: the output is 1 only if both inputs are 1. Symbol: a D shape.
OR: the output is 1 if either input is 1, or both are. Symbol: a curved shield shape.
NOT: has one input, and the output is the opposite of the input. Symbol: a triangle with a small circle at the output.
These are the same operators you use in code for conditions, such as Q = A AND B or Q = NOT A (more in the programming revision notes).
GCSE only: OCR J277 also names the operators: AND is conjunction, OR is disjunction and NOT is negation. Other valid notation is accepted in the exam, such as T and F for 1 and 0, or ∨ for OR. J277 uses only these three gates.
IGCSE only: draw gates with the symbols in section 4 of the 0478 syllabus. NOT is a single-input gate; every other gate is limited to two inputs. Three more gates, NAND, NOR and XOR, are in Q2.
Worked example: which gate does a security light need? (both boards)
A security light comes on (L = 1) only when movement is detected (M = 1) and it is dark (D = 1).
Step 1: find the inputs and the output: two inputs, M and D, and one output, L.
Step 2: "only when ... and ..." means both inputs must be 1, so it is an AND gate: L = M AND D.
Step 3: test it. Movement in daylight: M = 1, D = 0, so 1 AND 0 = 0, and the light stays off. Movement at night: M = 1, D = 1, so the output is 1.
Practise Q1: OCR questions · OCR mark scheme · Cambridge questions · Cambridge mark scheme
Q2: What do NAND, NOR and XOR gates do?
IGCSE only. OCR J277 uses AND, OR and NOT only, so GCSE students can skip this part. Cambridge 0478 adds three two-input gates:
NAND (NOT AND): the output is 0 only when both inputs are 1; otherwise it is 1. It gives the inverse of AND. Symbol: an AND shape with a small circle at the output.
NOR (NOT OR): the output is 1 only when both inputs are 0; otherwise it is 0. It gives the inverse of OR. Symbol: an OR shape with a small circle at the output.
XOR (also called EOR, exclusive OR): the output is 1 when the two inputs are different, and 0 when they are the same. Symbol: an OR shape with an extra curved line across the inputs.
Spot them in the words of a problem statement: "not both" means NAND, "neither ... nor" means NOR, and "either ... but not both" means XOR. In expressions they are written A NAND B, A NOR B and A XOR B.
Worked example: four gates, the same inputs (IGCSE only)
Work out the output of OR, XOR, NAND and NOR for each pair of inputs.
Step 1: A = 1, B = 1. OR gives 1. XOR gives 0, because the inputs are the same. NAND gives 0, because both inputs are 1. NOR gives 0, because an input is 1.
Step 2: A = 0, B = 0. OR gives 0 and XOR gives 0. NAND gives 1 and NOR gives 1: they are the opposites of AND (0) and OR (0).
Step 3: A = 1, B = 0. OR, XOR and NAND all give 1. NOR gives 0. So OR and XOR differ only when both inputs are 1.
Practise Q2: Cambridge questions · Cambridge mark scheme
Q3: How do you complete a truth table for a single logic gate?
Both boards. A truth table shows the output for every possible combination of inputs. With n inputs there are 2ⁿ rows: one input needs 2 rows, two inputs need 4 rows. List the inputs in binary counting order: 00, 01, 10, 11. Head the columns with the inputs (A, B) and the output (for example A AND B, or P).
A | B | A AND B | A OR B |
|---|---|---|---|
0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 |
1 | 0 | 0 | 1 |
1 | 1 | 1 | 1 |
For NOT, there is one input and two rows: 0 gives 1, and 1 gives 0.
GCSE only: you need the AND, OR and NOT tables, which are printed in the J277 specification. T and F may replace 1 and 0.
IGCSE only: you need the tables for all six gates. For the inputs 00, 01, 10 and 11 in order, NAND gives 1, 1, 1, 0, NOR gives 1, 0, 0, 0 and XOR gives 0, 1, 1, 0. Because every gate except NOT has exactly two inputs, a single-gate table never has more than 4 rows.
Worked example: identify the gate from its truth table (both boards)
An unknown two-input gate gives the outputs 0, 1, 1, 1 for the inputs 00, 01, 10, 11.
Step 1: the output is 0 only when both inputs are 0.
Step 2: it is 1 when either input is 1, or both. That is an OR gate. (GCSE only: the same table written as F, T, T, T is still OR.)
Step 3 (IGCSE only): compare the last row with XOR. XOR would give 0 for 11. Here the output is 1, so it is OR, not XOR. A gate giving 1, 0, 0, 0 would be NOR.
Practise Q3: OCR questions · OCR mark scheme · Cambridge questions · Cambridge mark scheme
Q4: How do you work out the output of a logic circuit with more than one gate?
Both boards. In a logic circuit (OCR calls it a logic diagram), gates are joined so that one gate's output becomes another gate's input. To find the output for given inputs, trace from left to right: work out each gate's output in turn and feed it into the next gate. Label the in-between outputs (for example D and E) so you do not lose track. A NOT gate on a line inverts only that one signal.
GCSE only: OCR J277 circuits use AND, OR and NOT only. You may be asked to complete or edit a part-drawn logic diagram, for example by adding the missing gate so it matches a scenario.
IGCSE only: circuits may also include NAND, NOR and XOR. They have at most three inputs and one output.

Worked example: trace a three-input circuit (both boards)
The circuit above has a NOT gate (D = NOT A), an OR gate (E = B OR C) and an AND gate that joins them (P = D AND E).
Step 1: A = 0, B = 1, C = 0. D = NOT 0 = 1. E = 1 OR 0 = 1. P = 1 AND 1 = 1.
Step 2: A = 1, B = 1, C = 1. D = NOT 1 = 0. E = 1 OR 1 = 1. P = 0 AND 1 = 0.
Step 3: describe it in words: P is 1 when A is 0 and B or C (or both) is 1.
Practise Q4: OCR questions · OCR mark scheme · Cambridge questions · Cambridge mark scheme
Q5: How do you complete a truth table for a logic circuit?
Both boards. A circuit with three inputs needs 2³ = 8 rows. Fill the inputs in binary order from 000 to 111: column A is 0000 1111, column B is 0011 0011 and column C is 0101 0101. Then add a working column for each in-between gate output, complete one column at a time by applying that gate's rule all the way down, and finish with the output column. Check that every input combination appears exactly once and every row has an output.
GCSE only: OCR J277 asks you to create, complete or edit truth tables for given scenarios, using AND, OR and NOT. T and F are accepted in place of 1 and 0.
IGCSE only: Cambridge 0478 asks you to complete a truth table from a problem statement, a logic expression or a logic circuit. The table usually has a "Working space" column between the inputs and the output. Circuits and expressions may include NAND, NOR and XOR, and there are never more than 3 inputs, so never more than 8 rows.
Worked example: the truth table for the Q4 circuit (both boards)
The circuit is P = (NOT A) AND (B OR C). D and E are working columns.
A | B | C | D = NOT A | E = B OR C | P = D AND E |
|---|---|---|---|---|---|
0 | 0 | 0 | 1 | 0 | 0 |
0 | 0 | 1 | 1 | 1 | 1 |
0 | 1 | 0 | 1 | 1 | 1 |
0 | 1 | 1 | 1 | 1 | 1 |
1 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 | 1 | 0 |
1 | 1 | 1 | 0 | 1 | 0 |
Step 1: column D: invert A, so 1 for the top four rows and 0 for the bottom four.
Step 2: column E: B OR C is 0 only when B and C are both 0 (rows 1 and 5).
Step 3: column P: D AND E is 1 only where both are 1, which is rows 2, 3 and 4. So P is 1 in 3 of the 8 rows.
Practise Q5: OCR questions · OCR mark scheme · Cambridge questions · Cambridge mark scheme
Q6: How do you write a logic expression from a circuit, and draw a circuit from an expression?
Both boards. A logic expression is a circuit written with operators, for example P = (A AND B) OR (NOT C). Brackets show the order: the innermost bracket is the first gate in the circuit.
Circuit to expression: start at the output gate and work back, writing each gate's inputs in brackets.
Expression to circuit: draw the innermost brackets first, then feed their outputs into the next gate.
NOT applies to what immediately follows it. NOT (A OR B) is not the same as (NOT A) OR B. With A = 0 and B = 1, NOT (0 OR 1) = 0, but (NOT 0) OR 1 = 1.
Check your answer by comparing the truth tables of the expression and the circuit.
GCSE only: OCR J277 expressions combine AND, OR and NOT only, and other valid notation (such as ∨ for OR) is accepted.
IGCSE only: Cambridge 0478 also asks you to write an expression from a problem statement or a truth table, and expressions may use NAND, NOR and XOR, for example X = (A XOR B) NOR C. Draw the circuit exactly as the expression is given, without simplifying it. From a truth table: for each row where the output is 1, AND the inputs together (with NOT on any input that is 0), then OR those terms.
Worked example: expressions both ways (both boards, Step 3 IGCSE only)
Step 1 (circuit to expression): in the Q4 circuit, the output gate is an AND. Its inputs come from a NOT gate on A and an OR gate on B and C, so P = (NOT A) AND (B OR C).
Step 2 (expression to circuit): for P = (A AND B) OR (NOT C), draw the bracketed parts first: an AND gate for A and B, and a NOT gate on C. Then join their two outputs into one OR gate. That is 3 gates.
Step 3 (truth table to expression, IGCSE only): a three-input truth table has X = 1 in two rows only: A = 0, B = 1, C = 0 and A = 1, B = 0, C = 1. The terms are ((NOT A) AND B) AND (NOT C) and (A AND (NOT B)) AND C, so X = (((NOT A) AND B) AND (NOT C)) OR ((A AND (NOT B)) AND C). Each AND has two inputs, as the syllabus requires.
Practise Q6: OCR questions · OCR mark scheme · Cambridge questions · Cambridge mark scheme
Q7: How do you turn a problem statement into a logic circuit?
Both boards. Exam scenarios describe a real system, such as an alarm or a machine, with sensors and switches as inputs.
Identify the inputs and the single output, and what 1 and 0 mean for each.
Map the wording to operators: "and" means AND, "or" means OR, and "not", "is off" or a condition that is the opposite of what an input's 1 means needs a NOT.
Write the expression first, then draw one gate per operator, inner parts first, joining their outputs into the final gate.
Read carefully: "only if", "either", "both" and "neither" change the gates you need.
Check the circuit by testing several rows against the scenario.
GCSE only: OCR J277 asks you to create logic diagrams for given scenarios using AND, OR and NOT. It sets no limit on the number of gates.
IGCSE only: draw the circuit for the statement as given, without simplification, using the 0478 section 4 symbols, with at most three inputs. Scenarios may need NAND, NOR or XOR: "either A or B but not both" is A XOR B.

Worked example: a drinks machine (both boards)
A drinks machine dispenses a drink (V = 1) when a drink is selected (S = 1) and the machine is not out of cups and not out of water. E = 1 means it is out of cups. W = 1 means it is out of water.
Step 1: the inputs are S, E and W; the output is V. E and W are 1 for the problem, so the statement needs NOT E and NOT W.
Step 2: write the expression: V = (S AND (NOT E)) AND (NOT W). That is 4 gates: two NOT gates and two AND gates, each AND with two inputs.
Step 3: test it. S = 1, E = 0, W = 0 gives V = 1: the drink comes out. S = 1, E = 1, W = 0 gives (1 AND 0) AND 1 = 0. Of the 8 possible rows, only S = 1, E = 0, W = 0 gives V = 1, which matches the scenario.
Practise Q7: OCR questions · OCR mark scheme · Cambridge questions · Cambridge mark scheme
Common exam mistakes in Boolean logic
Drawing a NOT gate without its small circle: it is then not a NOT gate. Adding a circle to AND or OR turns them into NAND or NOR.
Drawing a box with the gate's name written in it. You must draw the gate's shape.
Listing the inputs of a truth table in a random order, or missing a row. Count up in binary: 2 inputs give 4 rows, 3 inputs give 8.
Forgetting the NOT that a "not" or "is off" condition needs, so the circuit does the opposite of the scenario.
Treating NOT (A AND B) as (NOT A) AND B. NOT applies only to what immediately follows it.
(IGCSE) Mixing up OR and XOR: they differ only when both inputs are 1.
(IGCSE) Giving a gate three inputs, or simplifying the expression before drawing it. Every gate except NOT has two inputs; draw it as given.
Quick recap
Q1: AND gives 1 only if both inputs are 1; OR gives 1 if either or both are 1; NOT inverts its one input. Conjunction, disjunction and negation GCSE only.
Q2: (IGCSE only) NAND is NOT AND; NOR is NOT OR; XOR gives 1 when the inputs are different.
Q3: a truth table shows the output for every input combination: 2ⁿ rows, inputs in binary order.
Q4: trace a circuit left to right, labelling each in-between output; IGCSE circuits have at most 3 inputs and 1 output.
Q5: 3 inputs give 8 rows from 000 to 111; add a working column per gate, one column at a time.
Q6: brackets show the order of gates; NOT applies to what follows it; truth table to expression IGCSE only.
Q7: find the inputs and output, write the expression, then draw one gate per operator and test it.
Download the whole module
Frequently asked questions
Which logic gates do I need for OCR J277 and Cambridge IGCSE 0478?
OCR J277 uses only AND, OR and NOT. Cambridge IGCSE 0478 uses six gates: NOT, AND, OR, NAND, NOR and XOR, so part Q2 is for Cambridge students only.
How many rows does a truth table need?
A truth table needs 2ⁿ rows for n inputs: 2 rows for one input, 4 rows for two inputs and 8 rows for three inputs. List the inputs in binary counting order, from 000 to 111 for three inputs.
What is the difference between an OR gate and an XOR gate?
An OR gate outputs 1 when either input is 1 or both are. An XOR gate outputs 1 only when the two inputs are different, so when both inputs are 1, OR gives 1 but XOR gives 0. XOR is on Cambridge 0478 only.
What does a NAND gate do?
A NAND gate is an AND gate followed by NOT. Its output is 0 only when both inputs are 1, and 1 for every other combination. NAND is on Cambridge 0478 only.
How do you write a logic expression from a logic circuit?
Start at the output gate and work back towards the inputs, writing each gate's inputs in brackets. For example, a NOT gate on A and an OR gate on B and C that both feed an AND gate give P = (NOT A) AND (B OR C).
Is NOT (A AND B) the same as (NOT A) AND B?
No. NOT applies only to what immediately follows it. NOT (A AND B) inverts the output of the AND gate, but (NOT A) AND B inverts only A, so the two give different outputs for some inputs, such as A = 0 and B = 0.
Previous module: Languages and IDEs revision notes.
More help: browse the GCSE Computer Science revision hub.