MadeByZack
Sign in
Back

2.4.1 Boolean logic · Paper 2

Logic gates and truth tables

Each section has pictures and things to try, then its key points and key words. Exam practice is at the end of the page.

You need to know

  • The AND, OR and NOT gates: their symbols and truth tables
  • Create, complete and edit logic diagrams and truth tables
  • Combine more than one gate
  • Use logic to solve problems

Also accepted

  • Other notation is fine in the exam, e.g. T and F instead of 1 and 0, or ∧, ∨ and ¬ for AND, OR and NOT.

The three gates

A logic gate takes one or two inputs and gives one output. Every input and output is either 1 (on, true) or 0 (off, false).

AND: bothOR: at least oneNOT: flips it ABABA

Try it

Pick a gate and flip the switches. When does the bulb light up?

Key points

The AND gate

Before this: 2.2.1AND, OR and NOT

  • An AND gate has two inputs and one output.
  • The output is 1 only when both inputs are 1.
  • Its symbol is a D shape.
  • Real life: a car starts only if the key is turned AND the brake is pressed.
ABQ
ABA AND B
000
010
100
111

The OR gate

Before this: 2.2.1AND, OR and NOT

  • An OR gate has two inputs and one output.
  • The output is 1 when at least one input is 1.
  • The only time the output is 0 is when both inputs are 0.
  • Real life: a light comes on if the switch is pressed OR a motion sensor is triggered.
ABQ
ABA OR B
000
011
101
111

The NOT gate

Before this: 2.2.1AND, OR and NOT

  • A NOT gate has one input and one output.
  • It flips the input: 1 becomes 0, and 0 becomes 1.
  • Its symbol is a triangle with a small circle on the end.
  • Real life: a heater is on when the room is NOT warm.
AQ
ANOT A
01
10

Key words

Say what each one means, then tap to check.

Truth tables

A truth table shows the output for every possible combination of inputs.

How many rows?

InputsRows
12
24
38

Each extra input doubles the number of rows.

Fill in the inputs

Count up in binary, from 000 to 111.

The last column goes 0 1 0 1, the one before goes 0 0 1 1, and so on. That way you never miss a row.

When there is more than one gate, add a middle column for each gate's output, then work out the final column.

Try it

Fill in the truth table, then press Check.

Key points

Truth tables

Before this: The AND gateThe OR gateThe NOT gate

  • A truth table shows the output for every possible combination of inputs.
  • 1 means true (on) and 0 means false (off).
  • 2 inputs give 4 rows. 3 inputs give 8 rows.
  • Count up in binary to get every combination: 000, 001, 010 … 111.
  • Add a column for each gate in the middle, then work out the final output.

Key words

Say what each one means, then tap to check.

Combining gates

The output of one gate can be the input of another. Work through a diagram from left to right, and use brackets in the expression to show which gate comes first.

Try it

This circuit is P = (A AND B) OR NOT C. Flip the switches to find all 8 rows of its truth table.

AND NOT OR 000 01 P

Watch out

  • Brackets change the answer. NOT (A AND B) does the AND first, then flips it. NOT A AND B flips A first, then does the AND. Try both in the truth table above.
  • Expression to diagram: draw the gate inside the brackets first, then the gate that joins it to the rest.
  • Diagram to expression: start at the inputs, put each gate's output in brackets, and finish at the output.
  • Draw the shapes clearly (AND is a D, OR is a curved shield, NOT is a triangle with a circle) and label every input and the output.

Key points

Combining gates

Before this: Truth tables

  • Gates can be joined so the output of one becomes the input of another.
  • Work through a diagram from left to right.
  • Write the expression with brackets to show what happens first, e.g. P = (A AND B) OR NOT C.
  • In the truth table, add a column for each gate's output before the final column.
  • Brackets matter: NOT (A AND B) is not the same as NOT A AND B.
  • Exam circuits usually have up to 3 inputs.

Example: P = (A AND B) OR NOT C

ABCA AND BNOT CP
000011
001000
010011
011000
100011
101000
110111
111101

Key words

Say what each one means, then tap to check.

Logic in real situations

Exam questions often describe a real system, like an alarm or a machine, and ask you to write its logic. Do it in three steps:

  1. Find the logic words: and, or, not. Watch for either … or and but not too.
  2. Give each input a letter. The question usually does this for you.
  3. Put brackets round the part that must be worked out first.

Try it

Make the alarm ring. Then press Play to watch the exam answer, step by step.

Exam-style question

A fire alarm (F) rings when the system is switched on (O) and either the smoke detector (S) or the heat sensor (H) is triggered.

(a) Write a logic expression for F. (b) Draw the logic diagram. (c) Complete the truth table.

  1. Step 1: find the logic words. The question says and, and either … or.
  2. Step 2: name the inputs. The question gives the letters: S is the smoke detector, H is the heat sensor and O is the on switch. The output is F.
  3. Step 3: brackets first. Smoke OR heat sets it off, so write (S OR H). That's an OR gate.
  4. Step 4: add the rest. The system must also be on, so join the brackets to O with AND: F = (S OR H) AND O. That answers (a) and (b).
  5. Step 5: set up the truth table. 3 inputs give 2 × 2 × 2 = 8 rows. Count up in binary for the inputs, and add a middle column for S OR H.

F = (S OR H) AND O

OR 00 AND 00 Alarm F

Try it

Pick the right expression for each one.

A security light (L) comes on when it is dark (D) and movement is detected (M).

A kettle (K) heats while it is switched on (S) and the water is not boiling (B).

A school door (D) opens if a valid card is tapped (C) and the school is not in lockdown (L), or if the office presses the override button (T).

Key points

Logic in real situations

Before this: Combining gates

  • Exam questions describe a real situation and ask you to write the logic.
  • Look for the words and, or and not. Either … or means OR, and but not means AND NOT.
  • Give each input a letter, e.g. D = door open, S = alarm set.
  • Put brackets round the part that must be worked out first.
  • Example: an alarm sounds if the door is open AND the alarm is set: A = D AND S.

Key words

Say what each one means, then tap to check.

Also useful: AND, OR and NOT

Exam practice

21 questions in the style of the OCR exam, 47 marks in total. Try each one, then check the mark scheme.

The three gates

Question 1[1 mark]
State the output of an AND gate when A = 1 and B = 0.
Hint

How many of the inputs does an AND gate need to be 1?

State means give a short, clear answer. You don't need to explain it.

1 mark: one answer is enough.

Show mark scheme
  • 0
Question 2[2 marks]
A machine only runs when the guard is closed (G) AND the start button is pressed (S). Complete the truth table for the output R.
GSR
00?
01?
10?
11?
Hint

The machine needs both things to be true. Which row has G and S both as 1?

Complete means fill in every gap.

2 marks: check every part before you finish.

Show mark scheme
  • R is 0, 0, 0 …
  • … and 1 only when G = 1 and S = 1.

1 mark for the three 0s, 1 mark for the 1.

Question 3[1 mark]
State the only input combination that makes an OR gate output 0.
Hint

An OR gate outputs 1 if at least one input is 1. So when is it 0?

State means give a short, clear answer. You don't need to explain it.

1 mark: one answer is enough.

Show mark scheme
  • A = 0 and B = 0 (both inputs 0).
Question 4[2 marks]
Draw the symbol for an OR gate, and label its inputs and output.
Hint

OR is the curved shield shape, with two inputs on the left and one output on the right.

Draw means use the correct symbols, and label them.

2 marks: check every part before you finish.

Show mark scheme
  • Correct curved / shield shape.
  • Two inputs and one output labelled.

Don't accept: A D shape. That is an AND gate.

1 mark for the shape, 1 mark for the labels.

Question 5[1 mark]
State how many inputs a NOT gate has.
Hint

A NOT gate flips just one value.

State means give a short, clear answer. You don't need to explain it.

1 mark: one answer is enough.

Show mark scheme
  • 1
Question 6[2 marks]
State the output of each expression.
  1. NOT 0
  2. NOT (1 AND 1)
Hint

For b, work out the brackets first, then flip the answer.

State means give a short, clear answer. You don't need to explain it.

2 marks: make 2 separate points.

Show mark scheme
  • a) 1
  • b) 0

1 mark for each.

Truth tables

Question 7[1 mark]
State how many rows a truth table needs for a circuit with 3 inputs (not counting the heading row).
Hint

Each extra input doubles the number of rows. One input gives 2 rows.

State means give a short, clear answer. You don't need to explain it.

1 mark: one answer is enough.

Show mark scheme
  • 8
Question 8[3 marks]
Complete the truth table for P = NOT (A OR B).
ABP
00?
01?
10?
11?
Hint

Work out A OR B for each row first, then flip it.

Complete means fill in every gap.

3 marks: check every part before you finish.

Show mark scheme
  • 1 when A = 0 and B = 0.
  • 0 for 0,1 and 1,0.
  • 0 for 1,1.

Don't accept: 0, 1, 1, 1. That is A OR B. The NOT flips each result.

1 mark for each point.

Question 9[1 mark]
Identify the logic gate that has this truth table.
ABQ
000
011
101
111
Hint

Look at when Q is 0. Which gate is 0 only when both inputs are 0?

Identify means pick out or name the right thing. A short answer is enough.

1 mark: one answer is enough.

Show mark scheme
  • OR

Combining gates

Question 10[2 marks]
Write the logic expression for this circuit.
ABCP
Hint

Start at the inputs. Which gate do A and B go into? Put that in brackets, then add the last gate.

Write means write it with the input letters, AND, OR and NOT. Use brackets to show which part is worked out first.

2 marks: each correct part earns a mark, so get the gates and the brackets right.

Show mark scheme
  • (A AND B)…
  • …OR C, so P = (A AND B) OR C

1 mark for each point.

Question 11[4 marks]
Complete the truth table for P = (A OR B) AND NOT C.
ABCP
000?
001?
010?
011?
100?
101?
110?
111?
Hint

Add middle columns for A OR B and for NOT C. Then AND those two columns together.

Complete means fill in every gap.

4 marks: check every part before you finish.

Show mark scheme
  • P = 0, 0 for the first two rows.
  • P = 1, 0 for A = 0, B = 1.
  • P = 1, 0 for A = 1, B = 0.
  • P = 1, 0 for A = 1, B = 1.

Also accept: Extra working columns for A OR B and NOT C.

1 mark for each pair of rows.

Question 12[2 marks]
Draw a logic diagram for P = NOT (A AND B).
Hint

The brackets are done first, so draw the AND gate first. Then send its output into the NOT gate.

Draw means use the correct symbols, and label them.

2 marks: check every part before you finish.

Show mark scheme
  • An AND gate with inputs A and B.
  • Its output goes into a NOT gate, whose output is labelled P.

1 mark for each point. The shapes must be clear.

Question 13[2 marks]
Explain why NOT (A AND B) and NOT A AND B give different outputs.
Hint

Try A = 0 and B = 0 in both. In each one, what does the NOT apply to?

Explain means say what happens and why. Words like “because” and “so” help.

2 marks: aim for 2 things said, such as a point and then the reason for it.

Show mark scheme
  • In NOT (A AND B), the AND is done first and its output is flipped.
  • In NOT A AND B, only A is flipped before the AND, e.g. A = 0, B = 0 gives 1 and 0.

1 mark for each point. A correct example row can get the second mark.

Logic in real situations

Question 14[2 marks]
A car's warning light (W) comes on when the engine is running (E) and the seatbelt is not fastened (B). Write a logic expression for W.
Hint

Look for the word not. Which input does it go with?

Write means write it with the input letters, AND, OR and NOT. Use brackets to show which part is worked out first.

2 marks: each correct part earns a mark, so get the gates and the brackets right.

Show mark scheme
  • E AND …
  • … NOT B, so W = E AND NOT B

Also accept: W = NOT B AND E

1 mark for each point.

Question 15[3 marks]
A greenhouse fan (F) turns on when the system is switched on (S) and either the temperature is too high (T) or the humidity is too high (H). Write a logic expression for F.
Hint

"Either … or" goes in brackets. Then join the brackets to S.

Write means write it with the input letters, AND, OR and NOT. Use brackets to show which part is worked out first.

3 marks: each correct part earns a mark, so get the gates and the brackets right.

Show mark scheme
  • T OR H
  • in brackets / done first…
  • … AND S, so F = S AND (T OR H)

Also accept: F = (T OR H) AND S

1 mark for each point.

Question 16[2 marks]
Complete the truth table for W = E AND NOT B.
EBW
00?
01?
10?
11?
Hint

W can only be 1 when E is 1. NOT B means B must be 0.

Complete means fill in every gap.

2 marks: check every part before you finish.

Show mark scheme
  • W = 0 for both rows where E = 0.
  • W = 1 only when E = 1 and B = 0; 0 when E = 1 and B = 1.

1 mark for each point.

Question 17[3 marks]
A school door (D) opens if a valid card is tapped (C) and the school is not in lockdown (L), or if the office presses the override button (T). Write a logic expression for D.
Hint

Find the part joined by "and". Put it in brackets, then join it to T with OR.

Write means write it with the input letters, AND, OR and NOT. Use brackets to show which part is worked out first.

3 marks: each correct part earns a mark, so get the gates and the brackets right.

Show mark scheme
  • C AND NOT L
  • in brackets / done first…
  • … OR T, so D = (C AND NOT L) OR T

Don't accept: D = C AND NOT (L OR T). The override would never open the door.

1 mark for each point.

Mixed questions on the whole page

Question 18[3 marks]
Identify the logic gate that matches each description.
  1. It outputs 1 only when both inputs are 1.
  2. It has only one input.
  3. It outputs 0 only when both inputs are 0.
Hint

Picture the truth table for each gate. Which one needs both, which one flips, and which one needs at least one?

Identify means pick out or name the right thing. A short answer is enough.

3 marks: make 3 separate points.

Show mark scheme
  • a) AND
  • b) NOT
  • c) OR

1 mark for each.

Question 19[4 marks]
Complete the truth table for P = (NOT A) OR (B AND C).
ABCP
000
001
010
011
100
101
110
111
Hint

Add middle columns for NOT A and for B AND C. P is 1 if either middle column is 1.

Complete means fill in every gap.

4 marks: check every part before you finish.

Show mark scheme
  • P = 1, 1 for the first two rows (A = 0, B = 0).
  • P = 1, 1 for A = 0, B = 1.
  • P = 0, 0 for A = 1, B = 0.
  • P = 0, 1 for A = 1, B = 1.

1 mark for each pair of rows.

Question 20[3 marks]
Write the logic expression for this circuit.
ABCP
Hint

Start at the inputs. What happens to A? Which gate do B and C go into? Which gate joins the two together?

Write means write it with the input letters, AND, OR and NOT. Use brackets to show which part is worked out first.

3 marks: each correct part earns a mark, so get the gates and the brackets right.

Show mark scheme
  • NOT A…
  • …(B OR C)…
  • …joined with AND, so P = NOT A AND (B OR C)

Also accept: P = (B OR C) AND NOT A

1 mark for each point.

Question 21[3 marks]
A drinks machine (D) gives a drink when either a coin (C) or a card (K) is used, but not when the machine is empty (E). Write a logic expression for D.
Hint

"Either … or" goes in brackets. "But not" means AND NOT.

Write means write it with the input letters, AND, OR and NOT. Use brackets to show which part is worked out first.

3 marks: each correct part earns a mark, so get the gates and the brackets right.

Show mark scheme
  • C OR K, in brackets / done first…
  • …AND NOT E
  • So D = (C OR K) AND NOT E

Also accept: D = NOT E AND (C OR K)

Don't accept: D = C OR (K AND NOT E). A coin would still give a drink when the machine is empty.

1 mark for each point.