Specimen QP - Paper 2 OCR Computer Science GCSE
Specimen QP - Paper 2 OCR Computer Science GCSE
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 to answer.
BLANK PAGE
© OCR 2019
PMT
Section A
1 (a) Complete the truth table in Fig. 1 for the Boolean statement P = NOT(A AND B).
A B P
0 0 1
0 1
…………………………………
1 0
…………………………………
1 1 0
Fig. 1
[2]
(b) Tick () one box to identify the correct logic diagram for P = NOT(A AND B).
[1]
© OCR 2019 Turn over
PMT
num1 = ………………………………………………
………………………………………………
else
………………………………………………
endif [5]
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
[5]
© OCR 2019
PMT
3 The database table Results stores the results for each student in each of their chosen subjects.
Complete the SQL query to return all of the fields for the students who take Art.
SELECT ……………………………………………………………….…………….…….…….…………
FROM ……………………………………………………………….…………….…….…….…………
WHERE ……………………………………………………………….…………….…….…….…………
[3]
4 A program creates usernames for a school. The first design of the program is shown in the
flowchart in Fig. 2.
Start
INPUT
firstName
INPUT
surname
OUTPUT
username
Stop
Fig. 2
For example, using the process in Fig. 2, Tom Ward’s username would be TomWa.
(a) State, using the process in Fig. 2, the username for Rebecca Ellis.
……………………………………………………………………………………………………………. [1]
© OCR 2019
PMT
• If the person is a teacher, their username is the last 3 letters of their surname and then
the first 2 letters of their first name.
• If the person is a student, their username is the first 3 letters of their first name and then
the first 2 letters of their surname.
(i) What would be the username for a teacher called Fred Biscuit using the updated
process?
……………………………………………………………………………….……………………... [1]
(ii) Write an algorithm for the updated program design shown in question 4(b)(i).
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
……………………………………………………………………………………………..……………
…………………………………………………………………………………………….…………….
[6]
(a) State why the computer needs to translate the code before it is executed.
……………………………………………………………………………………………………………….. [1]
1 ..……………………………………………………………………………………………………………..
……………………………………………………………………………………………………………..…..
………………………………………………………………………………………………..………………..
……………………………………………………………………………………………..…………………..
2 ……………………………………………………………………………………………………………….
……………………………………………………………………………………………..…………………..
……………………………………………………………………………………………..…………………..
………………………………………………………………………………………………………………….
[4]
© OCR 2019
PMT
6 A program uses a file to store a list of words that can be used in a game.
Fig. 3
(a) Show the stages of a bubble sort when applied to data shown in Fig. 3.
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
[4]
Fig. 4
Show the stages of a binary search to find the word zebra using the data shown in Fig. 4.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
[4]
10
7 The area of a circle is calculated using the formula π × r2 where π is equal to 3.142 and r is the
radius.
A program is written to allow a user to enter the radius of a circle as a whole number between
1 and 30, then calculate and output the area of the circle.
01 radius = 0
02 area = 0.0
03 radius = input("Enter radius")
04 if radius < 1 OR radius > 30 then
05 print("Sorry, that radius is invalid")
06 else
07 area = 3.142 * (radius ^ 2)
08 print (area)
09 endif
(a) Explain, using examples from the program, two ways to improve the maintainability of the
program.
1 ……………………………………………………………………………………………………………….
………………………………………………..………………………………………………………………..
……………………………………………………………..…………………………………………………..
………………………………………………………………..………………………………………………..
2 ……………………………………………………………………………………………………………….
…………………………………………………………………..……………………………………………..
……………………………………………………………………..…………………………………………..
………………………………………………………………………………………………………..………..
[4]
1 ………………………………………………………………………………………………………………
2 …………………………………………………………………………………………………………..…..
[2]
© OCR 2019
PMT
11
(c) (i) Identify one item in the program that could have been written as a constant.
………………………………………………………………………………………………………. [1]
(ii) Give one reason why you have identified this item as a constant.
……………………………………………………………………………………………………… [1]
(d) Tick () one box in each row to identify whether each programming construct has or has not
been used in the program.
Sequence
Selection
Iteration
[3]
Identify two features of an IDE that might be used when writing the program.
1 ……………………………………………………………………………………………………………….
……………………………………………………………………………………………………………..…..
2 ……………………………………………………………………………………………………………….
………………………………………………………………………………………………………..………...
[2]
12
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.
8 A teacher researches the length of time students spend playing computer games each day.
(a) Tick () one box to identify the data type you would choose to store the data and explain
why this is a suitable data type.
String
Integer
Real
Boolean
Explanation: ……………………………………………………………………………………………….
…………………………………….………………………………………………….……………………..
[2]
© OCR 2019
PMT
13
(b) The program should only allow values from 0 to 300 inclusive as valid inputs. If the data entered
breaks this validation rule, an error message is displayed.
(i) Complete the following program to output "Invalid input" if the data does not meet
the validation rule.
endif
[3]
(ii) Complete the following test plan for the program in 8(b)(i).
Invalid input
Invalid
message displayed
300 Boundary
[2]
14
(c) Data for one week (Monday to Friday) is stored in a 2D array with the identifier minsPlayed.
Students
Stuart Wes Victoria Dan
0 1 2 3
Days Mon 0 60 30 45 0
of the
week Tue 1 180 60 0 60
Wed 2 200 30 0 20
Thu 3 60 10 15 15
Fri 4 100 35 30 45
The teacher wants to output the number of minutes Dan (column index 3) played computer
games on Wednesday (row index 2). The following code is written:
print(minsPlayed[3,2])
Write a line of code to output the number of minutes that Stuart played computer games on
Friday.
…………………………………………………………………………………………………………
……………………………………………………………………………………………………… [1]
© OCR 2019
PMT
15
(d) The teacher writes a program to add up and print out the total number of minutes student 2 played
computer games over 5 days (Monday to Friday).
total = 0
print(total)
Refine the program to be more efficient. Write the refined version of the algorithm.
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………..
[4]
16
x = 15
y = 0
while x > 0
y = y + 1
x = x – y
endwhile
print(y)
x y output
[4]
© OCR 2019
PMT
17
(f) A teacher writes an algorithm to store the name of the game a student plays each night (for
example "OCR Zoo Simulator").
valid = false
while(valid == false)
gamesPlayed = gameName.upper
valid = true
else
endif
endwhile
The algorithm needs testing to make sure the IF-ELSE statement works correctly.
Identify two different pieces of test data that can be used to test different outputs of the
algorithm. Give the output from the program for each piece of test data.
18
(g) The teacher asks students how long they spend completing homework. Students answer in
minutes and hours (for example 2 hours 15 minutes).
The teacher would like to create an algorithm that will display students’ inputs in minutes only.
(i) Identify the input and output required from this algorithm.
Input …….………………………………………………………………………………………………
……...……………………………………………………………………………………………………
Output …..………………………………………………………………………………………………
…….………………………………………………………………………….……………………........
[2]
(ii) A program is created to convert hours and minutes into a total number of minutes.
finalTotal = ………………………………………………………………..
print(finalTotal)
function ………………………………………………………………..
………………………………………………………………..
………………………………………………………………..
………………………………………………………………..
………………………………………………………………..
endfunction
[4]
© OCR 2019
PMT
19
(iii) The following flowchart outputs a message depending on how long each person has spent
playing computer games.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
[4]
© OCR 2019
PMT
20
If additional space is required, you should use the following lined page(s). The question
number(s) must be clearly shown in the margin(s).
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
Copyright Information:
OCR is committed to seeking permission to reproduce all third-party content that it uses in the 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 Copyright Team, The Triangle, Shaftesbury Road, Cambridge, CB2 8EA.
OCR is part of the Cambridge Assessment Group; Cambridge Assessment is the brand name of University of Cambridge Local Examinations
Syndicate (UCLES), which is itself a department of the University of Cambridge.
© OCR 2019