OCR GCSE Computer Science June 2025 Paper 2, Question 6(a): do the passwords match?
OCR J277/02 June 2025, Question 6(a): choose the correct OCR Exam Reference Language for inputting two passwords, then design an algorithm that outputs whether passA and passB match. Worked through, with the program to run.
Question 6(a) opens Section B of the OCR GCSE Computer Science Paper 2 sat on 20 May 2025 (J277/02). Part (i) is a tick box about how input and assignment are written (1 mark). Part (ii) is a three line algorithm (3 marks).
We do not copy the exam paper here. Open it beside this page: OCR June 2025 J277/02 question paper (PDF). When you have finished, check the mark scheme too.
Part (i): which statements are correct?
A visitor enters a password twice, and the two entries are stored in passA and passB. Four versions are offered. The correct one is the third:
passA = input("enter your password")
passB = input("enter your password again")
Why the others are wrong:
- One
inputcannot fill two variables joined withand. input(...) = passAis back to front. The variable being given a value goes on the left of the=."passA"in quotation marks is a string, not a variable. You cannot store anything in it.
Part (ii): design the check
if passA == passB then
print("passwords match")
else
print("passwords do not match")
endif
One mark for comparing the two variables, one for the right output when they are equal, one for the right output when they are not.
It says design, so a flowchart is accepted: a diamond for the decision with True and False labels, and a parallelogram for each output.
Where the marks are lost
=for the comparison. In OCR's reference language and in Python, one equals sign stores and two compare.elifwith nothing after it.elifneeds its own condition. Here a plainelseis right.pass A. No spaces in variable names. CopypassAandpassBexactly.- Inputting the passwords again. They are already stored. The mark scheme ignores the extra code, but it wastes time.
Run it
Both parts together. The robot's light is green when the passwords match.
The program
from bugbot import *
connect()
passA = input("enter your password: ")
passB = input("enter your password again: ")
if passA == passB:
led("green")
print("passwords match")
else:
led("red")
print("passwords do not match")
Questions
What is the answer to OCR J277 June 2025 Paper 2 Question 6(a)(ii)?
if passA == passB then print("passwords match") else print("passwords do not match") endif.
Which side of the equals sign does the variable go on?
The left. passA = input("...") stores what the user types in passA. The right hand side is worked out first, then stored in the variable named on the left.
What is the difference between = and ==?
A single = assigns a value to a variable. A double == compares two values and gives True or False.
More from this paper
- Question 5(d): Validate a 4 character PIN that must not be 1234 or 4321 6 marks
- Question 6(c): Write a function that returns a ticket price, then call it 6 marks
- Question 6(e): Sell tickets in a loop until none are left 6 marks
Every OCR J277 question we have worked
Learn it step by step
- F1.7 Input from the user Programming basics
- F2.2 Selection: if Decisions and loops
- F1.6 Variables, constants and assignment Programming basics
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.