All papers

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

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

Practise the past exam questions by topic

OCR J277 · Paper 2

9 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 3

(a)

State what is meant by the term syntax error. Give one example of a syntax error in a program.

[2]

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

A student writes an algorithm to input two numbers and add them together to create a total.

If the total is between 10 and 20 inclusive, "success" is output.

If the total is not between 10 and 20 inclusive, "warning" is output.

01 num1 = input("Enter a number") 02 num2 = input("Enter a number") 03 total = num1 + num1 04 if total >= 10 then 05 print("success") 06 else 07 print("warning") 08 endif

The algorithm does not work correctly.

Identify the line number of the two logic errors in the algorithm and refine the code to correct each logic error.

[4]

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

Show how a binary search will be used to find the number 10 in the following data set:

1 2 5 6 7 10 20

[3]

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

State one pre-requisite for a binary search algorithm.

[1]

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

Tick (✓) one box to identify the name of the sorting algorithm that splits data into individual items before recombining in order.

Question 3, shown as an image

[1]

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

Question 4

A program allows users to search for and watch videos. Users give a rating to the videos they watch.

(a)

Identify one input and one output for the program.

[2]

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

Describe one method of defensive design that can be used when creating the program.

[2]

Answer
Mark scheme for question 4(b)

Question 5

(a)

Complete the truth table for P = (A AND B) OR C

ABCP
000
001
010
011
100
101
110
111

[4]

Answer
Mark scheme for question 5(a)
(b)
Figure for question 5 Figure for question 5

[3]

Answer
Mark scheme for question 5(b)

Question 6

The variable message is assigned a value.

message = "abcd1234"

(a)

Complete the table to show the output when each statement executes.

The first output has been completed for you.

StatementOutput
print(message.length)8
print(message.upper)
print(message.left(4))
print(int(message.right(4))*2)

[3]

(b)

Write an algorithm in pseudocode to:

• store "Hello" in the variable word1

• store "Everyone" in the variable word2

• concatenate word1 and word2 to store "HelloEveryone" in the variable message

[3]

Question 7

Programs can be written in high-level languages or low-level languages.

(a)

Give two reasons why some programs are written in a low-level language.

[2]

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

Describe the benefits of using a compiler instead of an interpreter when writing a program.

[3]

Answer
Mark scheme for question 7(b)

Question 8

An algorithm stores the position of a character on a straight line as an integer. A user can move the character left or right.

The following algorithm:

• generates one random number between 1 and 512 (inclusive) to store as the position

• prompts the user to input a direction to move (left or right)

• takes a direction as input until a valid direction is input.

p = random(1, 512) print("The position is ", p) a = "" while a != "left" and a != "right" a = input("Enter direction, left or right") endwhile

(a)

Describe two ways to improve the maintainability of the algorithm.

[4]

(b)

If the character moves left, 5 is subtracted from the position. If the character moves right, 5 is added to the position.

The position of the character can only be between 1 and 512 inclusive.

The function moveCharacter():

• takes the direction (left or right) and current position as parameters

• changes position based on direction

• sets position to 1 if the new position is less than 1

• sets position to 512 if the new position is greater than 512

• returns the new position.

Complete the function moveCharacter()

function moveCharacter(direction, position)

endfunction

[6]

Question 9

Students take part in a sports day. The students are put into teams.

Students gain points depending on their result and the year group they are in. The points are added to the team score.

The team with the most points at the end of the sports day wins.

(a)

Data about the teams and students is stored in a sports day program.

(a)(i)

Identify the most appropriate data type for each variable used by the program.

Each data type must be different.

VariableExampleData type
teamName"Super-Team"
studentYearGroup11
javelinThrow18.2

[3]

(a)(ii)

The student names for a team are stored in an array with the identifier theTeam

An example of the data in this array is shown:

Index 0 1 2 3 4 5

Figure for question 9

A linear search function is used to find whether a student is in the team. The function:

• takes a student name as a parameter

• returns True if the student name is in the array

• returns False if the student name is not in the array.

Complete the design of an algorithm for the linear search function.

function linearSearch(studentName)

for count = 0 to …………….….....……………

[4]

(b)

endif

next count

return False

endfunction

Figure for question 9

[4]

(c)

The height a student jumps in the high jump needs to be input and validated. The height is entered in centimetres (cm) and must be between 40.0 and 180.0 inclusive.

(c)(i)

Write an algorithm to:

• take the height jumped as input

• output "VALID" or "NOT VALID" depending on the height input.

You must use either:

• OCR Exam Reference Language, or

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

[4]

(c)(ii)

The algorithm is tested using a range of tests.

Complete the table to identify an example of test data for each type of test.

Test data (height jumped in cm)Type of testExpected output
Normal"VALID"
Boundary"VALID"
Erroneous"NOT VALID"

[3]

(d)

The individual results for each student in each event are stored in a database.

The database table TblResult stores the times of students in the 100 m race. Some of the data is shown:

StudentIDYearGroupTeamNameTime
11GC111Valiants20.3
10VE110Super-Team19.7
10SM110Super-Team19.2
11JP211Champions19.65

Complete the SQL statement to show the Student ID and team name of all students who are in year group 11

SELECT StudentID,........

[4]

(e)

Abstraction and decomposition have been used in the design of the sports day program.

(e)(i)

Identify one way that abstraction has been used in the design of this program.

[1]

(e)(ii)

Identify one way that decomposition has been used in the design of this program.

[1]

(f)

An algorithm works out which team has won (has the highest score).

Write an algorithm to:

• prompt the user to enter a team name and score, or to enter "stop" to stop entering new teams

• repeatedly take team names and scores as input until the user enters "stop"

• calculate which team has the highest score

• output the team name and score of the winning team in an appropriate message.

You must use either:

• OCR Exam Reference Language, or

• A high-level programming language that you have studied

[6]

The paper as printed

Spotted a mistake on this page?Report a problem