OCR GCSE Computer Science Computational thinking, algorithms and programming (02), June 2025: Question 5
14 marks · Medium difficulty · Algorithm / Pseudo-code
Draw a logic circuit and truth table, match computational thinking techniques to examples, and write an algorithm to validate a 4-digit PIN.
Practise this questionQuestion
Question text
5 A security system protects online credit card payments. The system has three inputs:
Input Description
A True when the user enters their correct password
B True when the user enters their correct PIN
C True when the card is blocked
The output (P) is True if both of the following conditions are True:
• the user has entered either their correct password or has entered their correct PIN
• the card is not blocked.
(a) Draw the logic circuit for the security system
A
B
P
C
[3]
(b) Complete the truth table for P = A AND B
A B P
9 [2]
(c) Computational thinking techniques were used to design the security system.
Draw one line to match each computational thinking technique to its correct example.
Computational thinking Example
technique
The system is broken down
into modules for security and
payments.
Abstraction
There is an increase in
the amount of RAM in the
computer running the system
Decomposition
The user’s identity, PIN and
password are required. All
other data is ignored.
Algorithmic
thinking
The step-by-step process for
users to securely pay online
is designed.
10 [3]
(d) As part of the security system, the user is asked to choose a 4-digit value for their PIN. This PIN
cannot be 1234 or 4321
Create an algorithm that:
• takes the PIN as input as a string
• checks that the PIN is 4 characters in length
• checks that the PIN is not either “1234” or “4321”
• outputs "VALID PIN" if the PIN meets all of the criteria
• outputs "INVALID PIN" if the PIN does not meet all of the criteria.
You do not need to check that the digits entered are numeric.
… [6]
Mark scheme
Show the mark scheme
Question Answer Mark Guidance
5 (a) • Any use of an OR gate with 2 inputs 3 Gate diagrams must be correct. NOT must include
• NOT C circle; AND / OR must not include circle.
• Correctly joined by AND gate
FT for BP3 if appropriate (e.g. missing/wrong NOT
gate, wrong gate used instead of OR)
Max 2 if extra gates or system is not logically
correct.
5 (b) • All input possibilities for A, B (00, 01, 10, 2 P = A AND B
11), does not have to be in order…
• …Correct output for P (only 1 when A and B A B P
are both 1, 0 otherwise).
00 0
01 0
10 0
11 1
Accept T/F, Yes/No, ticks/crosses, etc.
Question Answer 20 Mark Guidance
5 (c) • Correct link for abstraction to third example 3 No mark for more than one connection from a box.
• Correct link for decomposition to first
example
• Correct link for algorithmic thinking to
bottom example
5 (d) • Input and storage/use of PIN 6 Example code
• Attempt at selection / condition controlled pin = input("Enter PIN")
loop… if pin.length == 4 and pin != "1234"
• …Correctly checks for 4 digits and pin != "4321" then
• …Correctly checks for both 1234, 4321 print("VALID PIN")
else:
• Correct output of “INVALID PIN” after
print("INVALID PIN")
sensible attempt at all three checks
• Correct output of “VALID PIN” after sensible
Note - | or || means OR in some languages. AND is &.
attempt at all three checks, only when PIN
is fully valid and no contradictory output BOD input and use/comparison of PIN as integer. No need
(e.g. printing “invalid PIN” as well) for quotation marks around 1234 / 4321. Allow equivalent
outputs.
If diagram/flowchart given, ignore shapes if
incorrect and mark text inside as algorithm. BP3 and 4 can be combined or as separate checks. If
combined, must logically work. BP3 and 4 can be
checks for positive or negative. Check must refer to
variable for both comparisons.
BP5 given if invalid output (once or multiple times) for all
invalid PINs even if valid also output. BP6 only given if
valid is output as the only output.
If sensible attempt at BP3 and BP4 (but incorrect), FT to
BP5 and 6.
Section A so candidates can respond in pseudocode,
structured English, flowcharts, etc. However, must not
simply be a repeat of the question.
How to answer it
Security Systems: Logic Gates, Computational Thinking & Algorithm Design
This 14-mark question assesses fundamental Component 02 topics across four linked parts:
- Logic Circuits (Part a): Translating written boolean criteria into standard logic gate symbols (AND, OR, NOT).
- Truth Tables (Part b): Completing a basic 2-input truth table for a standard boolean operator ( AND ).
- Computational Thinking (Part c): Matching key problem-solving concepts (Abstraction, Decomposition, Algorithmic Thinking) to practical descriptions.
- Algorithm Design (Part d): Writing structured pseudocode or high-level code involving user input, string length validation, compound conditional logic ( AND / OR ), and distinct user feedback.
Logic Circuit Diagram
Translating scenario specifications into standard logic gates
✅ Correct Logic & Connections
The problem states: "P is True if the user enters either correct password (A) OR correct PIN (B), AND the card is NOT blocked (NOT C)."
- Gate 1: An OR gate with inputs A and B .
- Gate 2: A NOT gate with input C .
- Gate 3: An AND gate taking the output of the OR gate and the output of the NOT gate, with its output going directly to P .
• Mark 1: Any standard OR gate correctly connected to inputs A and B.
• Mark 2: A NOT gate correctly connected to input C.
• Mark 3: Outputs of the first two gates correctly combined via an AND gate leading to output P.
🧠 Exam Technique: Drawing Gates
- OR Gate: Curved back line and pointed snout. Never put a bubble/circle at its output tip (that makes it a NOR gate!).
- NOT Gate: Must be a triangle with a distinct circle (inversion bubble) at the pointed front.
- AND Gate: Completely straight back edge and curved, rounded front. No bubble at the tip.
- Always ensure input/output lines touch the gate boundaries clearly with no ambiguous overlaps.
❌ Common Errors to Avoid
- Confusing AND and OR shapes: Drawing a flat back on the OR gate or curved back on the AND gate loses marks immediately.
- Missing inversion bubble: Drawing just a triangle for a NOT gate without the circle bubble.
- Unnecessary extra gates: Adding extra gates or nesting incorrectly caps the score at maximum 2 marks.
Truth Table for P = A AND B
Evaluating standard boolean AND logic
✅ Completed Truth Table
| A | B | P |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
• 1 mark for the correct output column: only 1 when both inputs are 1; 0 otherwise. (Accepts True/False or T/F).
💡 Key Knowledge: The AND Rule
For an AND logic operator:
- The output is 1 (True) only when both input A AND input B are 1.
- If any input is 0 (False), the result must be 0 (False).
Computational Thinking Matching
Identifying Abstraction, Decomposition, and Algorithmic Thinking
✅ Correct Matches
- Abstraction → "The user's identity, PIN and password are required. All other data is ignored."
Why: Abstraction is the removal of unnecessary details to focus only on the essential data. - Decomposition → "The system is broken down into modules for security and payments."
Why: Decomposition is breaking a complex problem down into smaller, more manageable sub-problems or modules. - Algorithmic thinking → "The step-by-step process for users to securely pay online is designed."
Why: Algorithmic thinking is defining clear, step-by-step instructions or rules to solve a problem.
Algorithm Design: PIN Validation
Writing a robust validation algorithm using string checks and logic
💡 The 3 Required Validation Rules
- Rule 1 (Length): Length must equal exactly 4 characters ( pin.length == 4 ).
- Rule 2 (Forbidden 1): Value must not be "1234" .
- Rule 3 (Forbidden 2): Value must not be "4321" .
✅ Model Solution (Python / OCR Pseudocode)
pin = input("Enter your 4-digit PIN: ") if len(pin) == 4 and pin != "1234" and pin != "4321": print("VALID PIN") else: print("INVALID PIN")• MP1: Input and variable storage of PIN.
• MP2: Attempt at selection ( if / else ) or loop.
• MP3: Correctly checking for length of 4.
• MP4: Correctly checking both 1234 and 4321.
• MP5: Outputting "INVALID PIN" when any criteria fail.
• MP6: Outputting "VALID PIN" only when all criteria are met without contradictory outputs.
🧠 Logic Alternative: Checking for Invalid First
You can also check invalid conditions first. Be careful with boolean logic operators!
pin = input("Enter PIN: ") if len(pin) != 4 or pin == "1234" or pin == "4321": print("INVALID PIN") else: print("VALID PIN")Notice that when checking for errors, you must use OR, not AND!
❌ Common Student Traps in Part (d)
- The "AND / OR" Trap: Writing if pin != "1234" or pin != "4321" . This condition is always True! (If a PIN is "1234", it is not "4321", so the OR passes). Always use and when chaining inequality checks.
- Shorthand Syntax Errors: Writing if pin != "1234" and "4321" . You must state the variable on both sides: pin != "1234" and pin != "4321" .
- Double Outputting: Writing multiple separate if statements without else , causing the program to output both "INVALID PIN" and "VALID PIN" for the same run.
- String Quotes: Since the question specifies the PIN is taken in as a string, compare with string quotes "1234" (though examiners will give benefit of the doubt for numeric values).
Topics
2.1 Algorithms · 2.2 Programming fundamentals · 2.3 Producing robust programs · 2.4 Boolean logic · 2.1.1 Computational thinking · 2.1.2 Designing, creating and refining algorithms · 2.2.1 Programming fundamentals · 2.2.3 Additional programming techniques · 2.3.1 Defensive design · 2.4.1 Boolean logic
Question and mark scheme from the OCR GCSE Computer Science examination, Computational thinking, algorithms and programming (02), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.