OCR GCSE Computer Science June 2025 Paper 2, Question 1: test data and a range check

OCR J277/02 June 2025, Question 1: decide whether 27, Hello, 105 and 100 are normal, boundary or invalid test data, then complete an algorithm that accepts numbers from 1 to 100. Worked through, with the check to run on all four values.

Past paper questionOCR J277/02June 2025 Paper 29 marksTesting

Question 1 of the OCR GCSE Computer Science Paper 2 sat on 20 May 2025 (J277/02, Computational thinking, algorithms and programming) is about a program that only accepts whole numbers from 1 to 100 inclusive. Part (a) classifies four pieces of test data (4 marks). Part (b) completes the algorithm and asks two vocabulary questions (5 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 (a): what kind of test data?

Test data Type Why
27 Normal comfortably inside 1 to 100
"Hello" Invalid / erroneous the wrong data type
105 Invalid / erroneous outside the range
100 Boundary the very edge of what is accepted

The question lets you tick more than one box in a row. For 100, boundary alone gets the mark, and so does boundary with normal, because 100 is also accepted.

105 is not boundary data. It is near the edge, but boundary data sits on the edge: 1 and 100 here. (Some courses also count the values just outside, 0 and 101. 105 is neither.)

Part (b)(i): complete the algorithm

The skeleton reads num, then has if num ...... AND ...... then, prints "accepted", has a gap, and prints "not accepted".

num = input("Enter a number between 1 and 100")
if num >= 1 AND num <= 100 then
    print("accepted")
else
    print("not accepted")
endif

The three gaps are >= 1, num <= 100 and else. > 0 and num < 101 are accepted as well.

Parts (b)(ii) and (iii)

  • The identifier of a variable: num. It is the only one.
  • A Boolean operator: AND. It joins two conditions. >= and <= are comparison operators, not Boolean ones.

Where the marks are lost

  • <= 100 without num. The second gap needs the variable again. num >= 1 AND <= 100 is not a valid condition, and the mark scheme insists on num.
  • elseif in the third gap. With no condition after it, it is wrong. The gap is a plain else.
  • > 1 and < 100. Inclusive means 1 and 100 are accepted.
  • input or print as the variable. Those are functions. And write the identifier on its own: num, not num = input(...).

Run it

The check as a function, run on the four values from part (a) and on both boundaries. A value that is not a number at all is caught before the range check.

27, 100 and 1 are accepted. Hello, 105 and 0 are not. Change >= 1 to > 1 and the boundary test on 1 fails.
The program
from bugbot import *
connect()

TESTS = ["27", "Hello", "105", "100", "1", "0"]

def check(text):
    if not text.isdigit():
        return "not accepted"
    num = int(text)
    if num >= 1 and num <= 100:
        return "accepted"
    else:
        return "not accepted"

for text in TESTS:
    print(text, check(text))
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 are the answers to OCR J277 June 2025 Paper 2 Question 1(a)?

27 is normal. "Hello" is invalid or erroneous. 105 is invalid or erroneous. 100 is boundary (boundary and normal is also accepted).

What is the difference between boundary and erroneous test data?

Boundary data is at the limit of what the program should accept, such as 1 and 100 for a range of 1 to 100. Erroneous data should be rejected: it is outside the range or of the wrong type.

What are the Boolean operators?

AND, OR and NOT. They combine or reverse conditions. Comparison operators such as ==, <, >= are different: they compare two values.

More from this paper

Every OCR J277 question we have worked · Guide: Logic gates and truth tables explained

Learn it step by step

  1. F6.3 Testing and test data Robust programs
  2. F6.1 Defensive design and validation Robust programs
  3. F2.3 else, elif and Boolean operators Decisions and loops
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.