All papers

Computer Science · OCR J277 · Computational thinking, algorithms and programming · June 2025

OCR GCSE Computer Science Computational thinking, algorithms and programming June 2025 question paper J277/02

Practise the past exam questions by topic

OCR J277 · Paper 2

6 questions
Report a problem
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Question 1

A program asks a user to enter a number. Only integer values between 1 and 100 (inclusive) are accepted. The program is tested.

(a)

Tick (✓) one or more boxes in each row to identify the type or types of test for each example of test data.

Figure for question 1

[4]

(b)

An algorithm is written for the program.

(b)(i)

Complete the algorithm for the program.

num = input("Enter a number between 1 and 100")

if num........ AND........ then

print("accepted")

print("not accepted")

endif

[3]

(b)(ii)

Give the identifier of one variable used in the algorithm in part (b)(i).

[1]

(b)(iii)

Give one Boolean operator used in the algorithm in part (b)(i).

[1]

Question 2

This flowchart uses iteration.

Figure for question 2
(a)

Complete the table by identifying how many times "OK" will be output for when each value is input.

Figure for question 2

[2]

(b)

Iteration is a programming construct.

(b)(i)

Identify and describe two different examples of iteration that can be used in a high-level language.

[4]

(b)(ii)

Give the names of two other programming constructs that are used in a high-level language.

[2]

(c)

A programmer implements the flowchart as a program in a high-level language using an Integrated Development Environment (IDE).

Identify and describe two tools that the programmer could use in the IDE to create a program from the flowchart.

[4]

Question 3

(a)

Show the steps that a merge sort would take to put the data set into ascending numerical order. 2, 7, 3, 1, 9, 6, 5, 4

[4]

Answer
Mark scheme for question 3(a)
(b)

Tick (✓) one box in each table to complete the descriptions.

Figure for question 3

A bubble sort compares pairs of values and then:

Figure for question 3

A sorting algorithm can sort data in an array. An array:

Figure for question 3

[3]

Answer
Mark scheme for question 3(b)
(c)

An algorithm can be used to search for a value in an array. The algorithm follows these steps:

• compares the first value in the array to the value being searched for

• stops if the comparison is true

• moves to the next value in the array if the comparison if false.

(c)(i)

Give the name of the searching algorithm described.

[1]

Answer
Mark scheme for question 3(c)(i)
(c)(ii)

Identify one other condition that will cause the algorithm to stop.

[1]

Answer
Mark scheme for question 3(c)(ii)

Question 4

An algorithm is written to read numbers from the external text file data.txt

Each number is checked when it is read from the external text file. The number is output to the user if it is not 0.

(a)

Complete the algorithm using the OCR Exam Reference Language statements in the box.

Not all statements are used.

data for if

myFile.close() myFile.readLine() input()

myFile.writeLine() open print

temp txt x

myFile =........ ("data.txt")

while NOT myFile.endOfFile()

if int (........) != 0

endif

endwhile

[5]

(b)

Identify how casting is used in this algorithm.

[1]

Question 5

A security system protects online credit card payments. The system has three inputs:

InputDescription
ATrue when the user enters their correct password
BTrue when the user enters their correct PIN
CTrue 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.

(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

Figure for question 5

[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]

Question 6

OCR Rockfest is a yearly music festival. Visitors buy tickets to attend and watch the music acts.

A computer system is created to sell tickets and store information about visitors and the music acts.

(a)

Visitors are asked to choose a password. The password is entered twice and stored in the variables passA and passB

(a)(i)

Tick (✓) one box to identify the correct OCR Exam Reference Language statements for the design of this task.

Figure for question 6

[1]

(a)(ii)

Design an algorithm that:

• checks if the passwords stored in passA and passB are the same

• outputs "passwords match" if they are the same

• outputs "passwords do not match" if they are not the same.

[3]

(b)

The database table TblMusic stores data about the music acts.

Some of the data in TblMusic is shown:

ActIDStageDaySetLength
1PlatinumSaturday0.5
2HillsSaturday1.5
3TriangleSunday1.0
4PlatinumSunday0.5

An SQL statement has been written to show ActID and Stage for all acts playing on Saturday. The SQL statement is incorrect.

SELECT ActID AND Stage FROM TblActs IF Day = Saturday

(b)(i)

Refine the SQL statement to correct the errors.

[4]

(b)(ii)

Identify one example of a record from TblMusic

[1]

(b)(iii)

Give the most appropriate data type for each field shown.

Figure for question 6

[2]

(c)

Tickets to the festival are £60 each. Visitors can buy multiple tickets. For example, a visitor buying 4 tickets would pay £240.

(c)(i)

Write a function, calculatePrice() that:

• takes the number of tickets to be purchased as a parameter

• calculates and returns the total price to pay.

You must use either:

• OCR Exam Reference Language, or

• a high-level programming language that you have studied.

[4]

(c)(ii)

Write an algorithm that:

• uses the function calculatePrice() to find the price for a visitor buying 3 tickets

• stores the result in the variable totalPrice

You must use either:

• OCR Exam Reference Language, or

• a high-level programming language that you have studied.

[2]

(d)

The number of different music acts on each of the three stages is stored in the array actNumbers.

Each index of the array represents one stage.

Question 6, shown as an image
Figure for question 6
Question 6, shown as an image

This algorithm adds up the total number of acts on all three stages.

01 count = 0

02 for x = 0 to 2

03 count = count + actNumbers[x]

04 next x

05 print(count)

(d)(i)

Complete the trace table for the algorithm. You may not need to use all rows in the table.

Figure for question 6

[4]

(d)(ii)

The array actNumbers is changed to include data for two more stages. The new array is shown:

Index 0 1 2 3 4

Figure for question 6

The algorithm from part (i) needs refining to work for the new array. The algorithm is repeated here:

01 count = 0

02 for x = 0 to 2

03 count = count + actNumbers[x]

04 next x

05 print(count)

Identify the line number that will need to be changed for the new array and write the updated line of code.

[2]

(d)(iii)

Refine line 05 in the algorithm to output "The total act count is " and then the content of the variable count

For example:

The total act count is 50

[1]

(e)

There are 500 tickets available for the music festival. The number of tickets currently available is stored in the variable tickets

Complete the algorithm to:

• prompt the user to enter how many tickets they would like and take this value as input

• output "Tickets booked" and reduce the value stored in tickets if there are enough tickets available

• output "Not enough tickets" if there are not enough tickets available

• repeat the steps until there are no tickets left.

You must use either:

• OCR Exam Reference Language, or

• a high-level programming language that you have studied

tickets = 500

[6]

The paper as printed

Spotted a mistake on this page?Report a problem