0% found this document useful (0 votes)
4 views

QP

This document is an exam paper for the GCSE (9–1) Computer Science subject, specifically focusing on computational thinking, algorithms, and programming. It includes instructions, sections for answering questions, and various programming tasks related to algorithms, data types, and logic. The total mark for the paper is 80, and it is structured into two sections with specific time allocations.

Uploaded by

achimote2021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

QP

This document is an exam paper for the GCSE (9–1) Computer Science subject, specifically focusing on computational thinking, algorithms, and programming. It includes instructions, sections for answering questions, and various programming tasks related to algorithms, data types, and logic. The total mark for the paper is 80, and it is structured into two sections with specific time allocations.

Uploaded by

achimote2021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Oxford Cambridge and RSA

Tuesday 21 May 2024 – Afternoon


GCSE (9–1) Computer Science
J277/02 Computational thinking, algorithms and programming
Time allowed: 1 hour 30 minutes

Do not use:
* 1 3 8 0 0 2 8 9 0 7 *

• a calculator

* J 2 7 7 0 2 *

Please write clearly in black ink. Do not write in the barcodes.

Centre number Candidate number

First name(s)

Last name

INSTRUCTIONS
• Use black ink.
• Write your answer to each question in the space provided. If you need extra space use
the lined pages at the end of this booklet. The question numbers must be clearly shown.
• Answer all the questions.

INFORMATION
• The total mark for this paper is 80.
• The marks for each question are shown in brackets [ ].
• This document has 20 pages.

ADVICE
• Read each question carefully before you start your answer.
• We advise you to spend approximately 50 minutes on Section A and approximately
40 minutes on Section B.

© OCR 2024 [601/8355/X] OCR is an exempt Charity


DC (ST) 342920/6 Turn over
2
SECTION A

We advise you to spend approximately 50 minutes on Section A.

1 Tick (✓) one box in each row to identify the programming construct where each keyword is used.

Programming construct
Keyword
Selection Iteration
if
for
while
[3]

2 An algorithm decides if a number is odd or even.


An odd number divided by 2 will give the remainder 1.

The flowchart statements have been written for the algorithm, but the flowchart is incomplete.

Complete the flowchart.

Start

INPUT num

if num MOD 2 == 0 OUTPUT "Odd"

OUTPUT "Even"

End

[4]
© OCR 2024
3
3
(a) State what is meant by the term syntax error. Give one example of a syntax error in a program.

Definition ..........................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................
[2]

(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.

Line number .....................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Line number ......................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................
[4]

© OCR 2024 Turn over


4
(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]

(ii) State one pre-requisite for a binary search algorithm.

..........................................................................................................................................................

..................................................................................................................................................... [1]

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

Bubble sort

Insertion sort

Merge sort
[1]

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.

Input .................................................................................................................................................

Output ..............................................................................................................................................
[2]

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

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [2]
© OCR 2024
5
5
(a) Complete the truth table for P = (A AND B) OR C

A B C P

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]

(b) Draw a logic circuit for P = NOT A AND (B OR C)

B
P

[3]

© OCR 2024 Turn over


6
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.

Statement Output

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]

© OCR 2024
7
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.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................
[2]

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

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [3]

© OCR 2024 Turn over


8
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.

1 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© OCR 2024
9
(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]

© OCR 2024 Turn over


10
BLANK PAGE

PLEASE DO NOT WRITE ON THIS PAGE

© OCR 2024
11
SECTION B

We advise you to spend approximately 40 minutes on Section B.

Some questions require you to respond using either the OCR Exam Reference Language or a
high-level programming language you have studied. These are clearly shown.

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.

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

Each data type must be different.

Variable Example Data type

teamName "Super-Team"

studentYearGroup 11

javelinThrow 18.2

[3]

© OCR 2024 Turn over


12
(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

Data Ali Eve Ling Nina Sarah Tom

theTeam

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 …………….….....……………

if theTeam[……………..…...…….………] == …………….….....…………… then

return …………….….....……………

endif

next count

return False

endfunction

[4]

© OCR 2024
13
(b) This algorithm calculates the number of points a student gets for the distance they throw in the
javelin:

01 javelinThrow = input("Enter distance")


02 yearGroup = input("Enter year group")
03 if javelinThrow >= 20.0 then
04 score = 3
05 elseif javelinThrow >= 10.0 then
06 score = 2
07 else
08 score = 1
09 endif
10 if yearGroup != 11 then
11 score = score * 2
12 endif
13 print("The score is", score)

Complete the trace table for the algorithm when a student in year 10 throws a distance of 14.3

You may not need to use all the rows in the table.

Line
javelinThrow yearGroup score Output
number

[4]
© OCR 2024 Turn over
14
(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.

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

(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
Type of test Expected output
(height jumped in cm)

Normal "VALID"

Boundary "VALID"

Erroneous "NOT VALID"

[3]

© OCR 2024
15
(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:

StudentID YearGroup TeamName Time


11GC1 11 Valiants 20.3
10VE1 10 Super-Team 19.7
10SM1 10 Super-Team 19.2
11JP2 11 Champions 19.65

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

SELECT StudentID, .................................................

FROM .............................................................................

.......................................................................................
[4]

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

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

..........................................................................................................................................................

..................................................................................................................................................... [1]

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

..........................................................................................................................................................

..................................................................................................................................................... [1]

© OCR 2024 Turn over


16
(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]

END OF QUESTION PAPER

© OCR 2024
17
BLANK PAGE

PLEASE DO NOT WRITE ON THIS PAGE

© OCR 2024
18
EXTRA ANSWER SPACE

If you need extra space use these lined pages. You must write the question numbers clearly in
the margin.

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

© OCR 2024
19

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

© OCR 2024
20

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

..................................................................................................................................................................

Oxford Cambridge and RSA


Copyright Information
OCR is committed to seeking permission to reproduce all third-party content that it uses in its assessment materials. OCR has attempted to identify and contact all copyright holders
whose work is used in this paper. To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced in the OCR Copyright
Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download from our public website (www.ocr.org.uk) after the live examination series.
If OCR has unwittingly failed to correctly acknowledge or clear any third-party content in this assessment material, OCR will be happy to correct its mistake at the earliest possible
opportunity.
For queries or further information please contact The OCR Copyright Team, The Triangle Building, Shaftesbury Road, Cambridge CB2 8EA.
OCR is part of Cambridge University Press & Assessment, which is itself a department of the University of Cambridge.

© OCR 2024

You might also like