[go: up one dir, main page]

0% found this document useful (0 votes)
66 views16 pages

J277-02 Computational Thinking Paper 2B - Answers

This document is a sample question paper and mark scheme for the OCR GCSE Computer Science (9-1) exam. It includes instructions, example questions, and answers related to programming concepts, algorithms, and database management. The document also outlines copyright and licensing information for the use of the materials provided.

Uploaded by

keyaanstefan
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)
66 views16 pages

J277-02 Computational Thinking Paper 2B - Answers

This document is a sample question paper and mark scheme for the OCR GCSE Computer Science (9-1) exam. It includes instructions, example questions, and answers related to programming concepts, algorithms, and database management. The document also outlines copyright and licensing information for the use of the materials provided.

Uploaded by

keyaanstefan
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/ 16

s

Sample Question Paper 2A Mark Scheme


OCR GCSE Computer Science (9-1)

Copyright

Copyright
© 2020 PG Online Limited
The contents of this unit are protected by copyright.
This Sample Paper, Sample Paper Mark Scheme and other associated files distributed with it
are supplied to you by PG Online Limited under licence and may be used and copied by you
only in accordance with the terms of the licence agreement between you and PG Online
Limited. Except as expressly permitted by the licence, no part of the materials distributed
with this unit may be used, reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, electronic or otherwise, without the prior written permission of PG
Online Limited.

Licence agreement
This is a legal agreement between you, the teaching institution, and PG Online Limited. PG
Online Limited grants to you a non-exclusive, non-transferable, revocable licence to use this
Sample Paper, Sample Paper Mark Scheme .and other associated files distributed with it in
the course of teaching by your teachers and/or employees.
The materials distributed with this unit may be copied and used by your teachers and/or
employees on a single site only in the course of their teaching. You warrant that you shall
not, and shall procure that each of your teachers and/or employees shall not, share in any
way any of the materials or part of the materials with any third party, including users on
another site or individuals who are teachers and/or employees of a separate institution. You
acknowledge and agree that the materials must remain with you, the teaching institution, and
no part of the materials may be transferred to another institution. You also warrant that you
shall not, and shall procure that each of your teachers and/or employees shall not, procure,
authorise, encourage, facilitate or enable any third party to reproduce these materials in
whole or in part without the prior permission of PG Online Limited.
In consideration of the licence granted to you, you shall indemnify PG Online Limited against
all liabilities, costs, expenses, damages and losses (including but not limited to any direct,
indirect or consequential losses, loss of profit, loss of reputation and all interest, penalties
and legal costs and all other professional costs and expenses) suffered or incurred by PG
Online Limited arising out of or in connection with the exercise by you of your rights granted
under this licence.

2
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

Please write clearly, in BLOCK CAPITALS and black ink

Centre number Candidate number

First names(s)

Surname

Date of Exam Time allowed: 1 hour 30 minutes

GCSE (9–1) Computer Science


J277/02 Computational thinking, algorithms and programming

PAPER 2B
DO NOT USE
• A calculator.

INSTRUCTIONS
• Write in black ink.
• Write your answer to each question in the space provided.
• Answer all the questions.

INFORMATION
• The total mark for this paper is 80.
• The marks for each question are shown in brackets [ ].
• Quality of written communication will be assessed in this paper in questions marked
with an asterisk (*).
• The student version of this paper has 15 pages.
ADVICE
• Read each question carefully before you start to answer.

3
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

Section A
1. A two-player computer game gives players a bank account each. An amount of starting
money is given, followed by a random amount of money.
1 const START_MONEY = 1500
2 playerABank = START_MONEY
3 playerBBank = START_MONEY
4 playerABank = playerABank + random(0,1000)
5 playerBBank = playerBBank + random(0,1000)
6 print(playerABank)
7 print(playerBBank)
8 START_MONEY = START_MONEY * 2

(a) Identify one constant used in the program code. [1]


START_MONEY (1)
(b) Identify one variable used in the program code. [1]
playerABank (1)
playerBBank (1)
(c) Identify one function used in the program code. [1]
random / random() / random(0,1000) (1)
(d) Explain why line 8 will cause an error in the program. [2]

A constant cannot be changed (during runtime) (1)


… but the line of code is trying to double its value (1)
You cannot assign a value to a constant (1)
… as constants cannot be changed (at runtime) (1)
(e) State the maximum value that could be output for playerABank on line 6. [1]
2500 (1)

4
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

2. A software company is making a new address book app which will have the following
features:
• Add a name, email address, address and date of birth
• Search for a name
• Show a reminder a week before a birthday
• Send automatic emails such as on a birthday
• Add notes to any name
(a) Draw a structure diagram for this new software. [3]

Structure diagram layout with subsections (1)


Titles are short and show the structure of the problem (1)
A logical structure that helps to understand the components of the problem (1)
Other titles can be in boxes and the layout can be different, e.g. “Add notes” could
be a subsection of “address book”.
E.g.

5
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(b) The program stores a list of names. An example is shown in Fig. 1.

Eva Grayson Liam Milo Muhammad Oliver Penelope Sophia Zainab

Fig. 1
Show the stages of a binary search when an attempt is made to find the name Ada
in the list. [5]
• Compare Ada to Muhammad (1)
• Less than, so split and take left side (1)
• Further comparison (1 or 2 depending on choices made) (1)
• Final comparison with Eva… (1)
• …which fails, therefore Ada is not in the list (1)
e.g.
Compare Ada to Muhammad.
It is less than so binary search left.
Compare to Grayson.
It is less than so binary search left.
Compare to Eva.
It is less than, but there is no more list left, so Ada is not in the list.
(c) State one pre-requisite that the list must have for a binary search to be
carried out. [1]
It must be sorted (1)
It must be in alphabetical order (1)
3. (a) Complete the truth table for Fig. 1 for the Boolean statement
P = (NOT A) OR (NOT B). [2]
A B P
0 0 1
0 1 1
1 0 1
1 1 0

6
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(b) Complete the following logic diagram for P = (NOT A) OR (NOT B). [3]

• Correct NOT symbol (1)


• Correct OR symbol (1)
• Correctly connected (1)

4. A website has been set up to teach programming. They have chosen to teach a high-
level language.
(a) One of the first topics on the website is arithmetic operators.
Two of the operators mentioned are * and ^. State the meaning of each of these
operators. [2]
* multiplication (1)
^ exponentiation / to the power of (1)
(b) Before students can run their programs, they first need to compile them.
Explain what happens when a program is compiled. [2]
A translator will translate the source code / a compiler will compile the source code
…. (1)
…into the binary instructions / executable file (1)
This can then be executed / run (1)
The binary instructions / executable file is specific to the CPU that the program will be
run on (1)
The compiler reports errors at the end of compilation (1)

7
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(c) The website tells students to install an Integrated Development Environment (IDE)
to develop their programs.
One facility which the IDE offers is an editor which is used to enter and edit each
program.
Other than entering and editing a program, state two other ways that an
editor can help a programmer develop a program. [2]
Syntax highlighting / making different parts of code different colours (1)
Displaying line numbers (1)
Code folding / allowing sections of code to be hidden (1)
Highlight sections of code where there are errors (1)
Code completion (1)
Auto indentation (1)

5. A student sits two papers for an exam. A program is written to calculate the average of
the two results.
1 paperOne = int(input("Paper 1 result: "))
2 paperTwo = int(input("Paper 2 result: "))
3
4 //find average of two papers
5 total = paperOne + paperTwo
6 average = total / 3
7 print(average)
8
9 //say if they improved
10 if paperTwo > paperOne then
11 print("You improved")
12 else
13 print("You didn’t improve")

(a) Lines 1 and 2 contain the instruction int(…) which is used for casting.
Explain the need for casting in these two lines of the program. [2]
The input will always be a string (1)
Which needs to be converted/cast into an integer (1)
… so that it can be used in calculations (later in the program) (1)
(b) State the purpose of // in lines 4 and 9. [1]
It shows that a comment will follow (1)
(c) In line 5, the + symbol means addition.
If paperOne and paperTwo held strings, state what operation the + symbol
would perform. [1]
Concatenation
(d) Identify the logic error in the program. [1]
Line 6 - It divides total by 3 / it should divide total by 2 (to find the average) (1)

8
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(e) One basic programming construct used in the program is a sequence.


Identify one other basic programming construct used to control the flow of the
program. [1]
Selection (1)
Do not accept iteration as it is not used in this program.
(f) When paperOne and paperTwo store the same values, state the output
from the program. [1]
"You didn’t improve"

Accept with or without quote marks.


(g) The program has been written in such a way as to make it easy to maintain.
Identify two features of the program that make it maintainable. [2]
Use of comments (1)
Naming conventions / meaningful variable names (1)
Indentation (inside the IF/ELSE statements) (1)
(h) The table below shows key features of different types of testing that could be used
as part of the program’s development.
Tick (✓) one box in each row to match the feature with the most appropriate
type of test. [2]

Key feature of type of test Iterative testing Final/terminal testing


Testing carried out
throughout the development ✓
of the program
Testing carried out at the end

of production

6. A restaurant has a menu which is stored in a database table named menuPrice.

menuItem price stock


Macaroni Cheese 6.50 15
Pizza 12.00 18
Burger 9.90 16
Salad 6.25 17
Steak 17.50 11

(a) The table below shows fields in the database and possible data types.
Tick (✓) one box in each row to choose the correct data type for each field. [3]

Field Integer Real Boolean Character String


menuItem ✓
Price ✓
Stock ✓

9
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(b) The restaurant needs to print the lunch menus for customers. These should only
have items with a price of less than 10.00.
Complete the SQL query to return the menuItem and Price for all items that are
under 10.00. [3]

SELECT menuItem, Price


FROM menuPrice
WHERE price < 10.00
Accept WHERE price < 10.

7. The file named usernames.txt contains a list of usernames that are allowed access to a
computer system. One username is contained on each line.
An administrator has changed all usernames to have the number 1 at the end.
The program will:
• read all the usernames stored in usernames.txt
• put 1 at the end of each username
• save the new usernames to a file named outputfile.txt
(a) The first username in the file is trobinson. Write the new username
that will be stored in outputfile.txt. [1]
trobinson1
(b) Write an algorithm for the program. Remember that it will need to make
use of basic file handling operations. [6]
• Open file usernames.txt and Open file outputfile.txt / create new file
outputfile.txt
• While there are more lines to read from usernames.txt / while not at end of
file
• … read the line of text
• … concatenate 1 to the end of the line / line = line + "1"
• Write the new line of text to outputfile.txt
• Close the usernames.txt, close outputfile.txt
1 mark for each bullet.
e.g.
open the file usernames.txt
open the file outputfile.txt
while not at end of file
read the line of text into a variable named line
line = line + "1"
write the line to outputfile.txt
close usernames.txt
close outputfile.txt

10
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

Section B
We advise you to spend at least 40 minutes on this section.

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 at a school sports day records the times of students in a race.


The time of each racer is given in seconds. For example, 102.3 seconds would be given
if a racer took 1 minute 42.3 seconds.
Valid times can be entered between 1 and 3600 inclusive. If an invalid time is entered,
an error message is output.
(a) Complete the following program to output "Invalid input" if the time entered
is not valid. [2]
You must use either:
• OCR Exam Reference Language, or
• A high-level programming language that you have studied.
seconds = input("Enter seconds for race")
if seconds < 1 or seconds > 3600 then
print("Invalid input")
endif

(b) Complete the following test plan for the program in 8(a). [3]

Test data Test type Expected result


500.2 Normal Value accepted
3600 Boundary Value accepted
3601 Invalid "Invalid input"

11
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(c) A program is created that will convert the number of seconds taken in a race into
minutes and seconds. A sub program will be used for the conversion.
For example, if 102.3 seconds is input, the output will be 1min42.3.
Complete the program. [5]
You must use either:
• OCR Exam Reference Language, or
• A high-level programming language that you have studied.
seconds = float(input("Enter seconds for race"))
outputString = convertToMin(seconds)
print(outputString)

function convertToMin(secs)
theMins = secs DIV 60
theSecs = secs MOD 60
output = str(theMins) + "min" + str(theSecs)
return output
endfunction

• Function name and parameter with parameter used correctly in program


• Minutes calculated correctly using integer division
• Seconds calculated correctly using modulus
• Concatenation correctly applied
• Output is returned
Allow alternative parameter name to secs.
Allow alternative variable names for theMins and theSecs.
Allow return str(theMins) + "min" + str(theSecs) to all be in one line.
Accept answers that haven’t cast numbers to a string for the output.
Allow alternatives to DIV such as // .
Allow alternatives to MOD such as % .
Five runners’ times for the 100 metres race have been stored in an array named
oneHundred which is shown in the following table.

0 1 2 3 4
12.5 12.3 10.4 11.25 10.9
(d) The following line of code is run:
racers = oneHundred.length
State the value stored in the variable racers once the line of code has been run. [1]
5 (1)

12
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(e) The following program determines the fastest race time: [5]
fastestTime = oneHundred[0]
if oneHundred[1] < fastestTime then
fastestTime = oneHundred[1]
endif
if oneHundred[2] < fastestTime then
fastestTime = oneHundred[2]
endif
if oneHundred[3] < fastestTime then
fastestTime = oneHundred[3]
endif
if oneHundred[4] < fastestTime then
fastestTime = oneHundred[4]
endif
print(fastestTime)

Refine the program so that it will work with any array length.
You must use either:
• OCR Exam Reference Language, or
• A high-level programming language that you have studied.

• Initialise fastestTime to the first element of the array and print out the
fastestTime (as per the original program)
• Use of a FOR loop or FOR … IN loop
• Use of array.length to determine the arrays length – accept use of racers
variable from 8(d). Accept use of FOR…IN loop which iterates through the
array.
• Correct if statement to determine if the time is faster
• Store the current item in array as the fastestTime if it is lower
e.g.
fastestTime = oneHundred[0]
for i = 0 to oneHundred.length
if oneHundred[i] < fastestTime then
fastestTime = oneHundred[i]
endif
next i
print(fastestTime)

e.g.
fastestTime = oneHundred[0]
for i in range(0, oneHundred.length):
if oneHundred[i] < fastestTime:
fastestTime = oneHundred[i]
print(fastestTime)

13
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

e.g.
fastestTime = oneHundred[0]
for time in oneHundred:
if oneHundred[i] < fastestTime:
fastestTime = oneHundred[i]
print(fastestTime)

9. Look at the following program:


x = 5
for i = 0 to 4
x = x + 5
next i
print(x)

(a) Complete the trace table to test this program. [4]

x i Output
5 0
10 1
15 2
20 3
25 4
30 30

x i Output Marks
5 0 MP1
10 1 MP2
15 2
20 3 MP3
25 4
30
30 MP4

• One mark for first row


• One mark for rows 2 and 3
• One mark for rows 4,5,6
• One mark for correct output (this may be in any position)

14
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(b) The program has been refined with a new algorithm which will produce the same
output.
Complete the new program below by adding one line of code. [1]
You must use either:
• OCR Exam Reference Language, or
• A high-level programming language that you have studied.
x = 5
x = x * 6
print(x)
10. A program has a 2D array named alphabet. This array stores each letter of the
alphabet along with the frequency that the letter occurs in a sentence. A table showing
the array is given below.

0 1
0 A The letter L would be referenced by the code:
1 B alphabet[11,0]
2 C Look at the following program which works out the
3 D frequency of each letter in a sentence.
4 E sentence = "A VERY LARGE HOUSE"
5 F for i = 0 to sentence.length
6 G for j = 0 to alphabet.length
if sentence[i] == alphabet[j,0]
7 H
alphabet[j,1] = alphabet[j,1] + 1
8 I endif
9 J endfor
10 K endfor

11 L
12 M
13 N
14 O
15 P
16 Q
17 R
18 S
19 T
20 U
21 V
22 W
23 X
24 Y
25 Z

15
Sample Question Paper 2A Mark Scheme
OCR GCSE Computer Science (9-1)

(a) Describe how the algorithm works. [4]


• It loops through each letter in the sentence
• It then compares each letter with each of the letters in the alphabet
• If they match…
• It increases the frequency of the letter by one / increments the frequency for
the letter
(b) Explain the difference between the == operator and the = operator. [2]
The == is used for a comparison (1)
The = is used for assignment (1)
(c) Refine the program so that it will output each item from the alphabets array
once the frequencies have been calculated. [3]
The format of the output should be as follows:
A:2
B:0
C:0
D:0
E:3
You must use either:
• OCR Exam Reference Language, or
• A high-level programming language that you have studied.

• Loop through the alphabet array…


• … from 0 to alphabet.length
• Concatenate alphabet[i][0] with ":" and alphabet[i][1]
E.g.
for i in range(0,len(alphabet)):
print(alphabet[i,0] + ":" + str(alphabet[i,1]))
E.g.
for i = 0 to alphabet.length
print(alphabet[i][0] + ":" + str(alphabet[i][1]))

16

You might also like