OCR GCSE Computer Science June 2024 Paper 2, Question 5: a truth table and a logic circuit
OCR J277/02 June 2024, Question 5: complete the eight row truth table for P = (A AND B) OR C, then draw the logic circuit for P = NOT A AND (B OR C). Worked row by row, with a program that prints both truth tables.
Question 5 of the OCR GCSE Computer Science Paper 2 sat on 21 May 2024 (J277/02) is two logic questions: fill in the P column of a three input truth table (4 marks), then draw a circuit from an expression (3 marks).
We do not copy the exam paper here. Open it beside this page: OCR June 2024 J277/02 question paper (PDF). When you have finished, check the mark scheme too.
Part (a): P = (A AND B) OR C
Brackets first. Add a working column for A AND B, which is 1 only when both are 1. Then P is 1 when that column is 1 or C is 1.
| A | B | C | A AND B | P |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
A quick check: P should be 1 in every row where C is 1 (that is every second row), plus the row 1 1 0. Five 1s in all.
There is one mark for each pair of rows, so one slip costs one mark, not four.
Part (b): draw P = NOT A AND (B OR C)
Work from the inputs towards P.
- A goes into a NOT gate: a triangle with a small circle on its point.
- B and C go into an OR gate: the shape with a curved back and a pointed front.
- The outputs of the NOT gate and the OR gate go into an AND gate: the D shape. Its output is P.
One mark for NOT A, one for B OR C, and one for an AND gate with two inputs. An extra or missing gate caps you at 2.
NOT only applies to A here. There are no brackets round A AND ..., and NOT is worked out before AND.
Where the marks are lost
- Doing the OR first in part (a). The brackets say
A AND Bcomes first. - Forgetting the circle on the NOT gate. Without it the shape is a buffer, not a NOT. No other gate has a circle at GCSE.
- A NOT gate on the output. That would be NOT (A AND (B OR C)), a different expression.
- AND and OR shapes swapped. AND has a flat back and a round front. OR has a curved back and a pointed front.
Run it
Python has and, or and not, so it can print any truth table. This one prints both expressions from the question. The P column of the second table is what your circuit should produce.
The program
from bugbot import *
connect()
print("A B C (A AND B) OR C")
for A in [0, 1]:
for B in [0, 1]:
for C in [0, 1]:
P = (A and B) or C
print(A, B, C, " ", int(P))
print("A B C NOT A AND (B OR C)")
for A in [0, 1]:
for B in [0, 1]:
for C in [0, 1]:
P = (not A) and (B or C)
print(A, B, C, " ", int(P))
Questions
What is the answer to OCR J277 June 2024 Paper 2 Question 5(a)?
Reading down the P column: 0, 1, 0, 1, 0, 1, 1, 1.
How do I fill in a truth table with three inputs?
List all eight combinations of the inputs in binary counting order, from 000 to 111. Work out any bracketed part in its own column first, then combine that column with the remaining input.
Which comes first in a logic expression: NOT, AND or OR?
Brackets first, then NOT, then AND, then OR.
More from this paper
- Question 2: Complete a flowchart that decides odd or even with MOD 4 marks
- Question 3(a), (b): Define a syntax error, then correct two logic errors in a range check 6 marks
- Question 3(c): Show a binary search for 10, its pre-requisite, and name merge sort 5 marks
- Question 6: String methods: upper, left, right with a cast, and concatenation 6 marks
- Question 8: Maintainability, and a function that moves a character and keeps it in range 10 marks
Every OCR J277 question we have worked · Guide: Logic gates and truth tables explained
Learn it step by step
- F9.1 Logic gates and truth tables Logic and computer systems
- F9.2 Logic circuits and expressions Logic and computer systems
This is our own explanation of a published exam question. It is not written or endorsed by OCR, and the question paper and mark scheme remain OCR's copyright. Read them on OCR's site with the links on this page.