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.

Past paper questionOCR J277/02June 2025 Paper 24 marksWrite a program

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 input cannot fill two variables joined with and.
  • input(...) = passA is 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.
  • elif with nothing after it. elif needs its own condition. Here a plain else is right.
  • pass A. No spaces in variable names. Copy passA and passB exactly.
  • 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.

Type the same password twice, then run it again with a slip in the second one. Capital letters count: Rock and rock do not 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")
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

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

Every OCR J277 question we have worked

Learn it step by step

  1. F1.7 Input from the user Programming basics
  2. F2.2 Selection: if Decisions and loops
  3. F1.6 Variables, constants and assignment Programming basics
Open the lessons

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.