0% found this document useful (0 votes)
23 views15 pages

J277-02 Computational Thinking Paper 2B

This document is a sample question paper for the OCR GCSE Computer Science exam, specifically for the Computational Thinking, Algorithms, and Programming section. It includes instructions, mark schemes, and various programming-related questions covering topics such as constants, variables, functions, binary search, truth tables, and SQL queries. The paper is designed to assess students' understanding and application of computer science concepts and programming skills.

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)
23 views15 pages

J277-02 Computational Thinking Paper 2B

This document is a sample question paper for the OCR GCSE Computer Science exam, specifically for the Computational Thinking, Algorithms, and Programming section. It includes instructions, mark schemes, and various programming-related questions covering topics such as constants, variables, functions, binary search, truth tables, and SQL queries. The paper is designed to assess students' understanding and application of computer science concepts and programming skills.

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/ 15

Sample Question Paper 2B 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 (*).
• This document has 15 pages.
ADVICE
• Read each question carefully before you start to answer.

GCSE Computer Science (9-1) - J277 1


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B 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]

(b) Identify one variable used in the program code. [1]

(c) Identify one function used in the program code. [1]

(d) Explain why line 8 will cause an error in the program. [2]

(e) State the maximum value that could be output for playerABank on line 6. [1]

GCSE Computer Science (9-1) - J277 2


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B 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]

(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
(b) Show the stages of a binary search when an attempt is made to find the name Ada
in the list. [5]

GCSE Computer Science (9-1) - J277 3


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-1)

(c) State one pre-requisite that the list must have for a binary search to be
carried out. [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

0 1 1

1 0 1

1 1

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

GCSE Computer Science (9-1) - J277 4


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-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]
*

(b) Before students can run their programs, they first need to compile them.
Explain what happens when a program is compiled. [2]

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

GCSE Computer Science (9-1) - J277 5


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-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]

(b) State the purpose of // in lines 4 and 9. [1]

(c) In line 5, the + symbol means addition.


If paperOne and paperTwo held strings, state what operation the + symbol
would perform. [1]

(d) Identify the logic error in the program. [1]

GCSE Computer Science (9-1) - J277 6


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B 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]

(f) When paperOne and paperTwo store the same values, state the output
from the program. [1]

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

(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

GCSE Computer Science (9-1) - J277 7


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-1)

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

FROM ____________________________________________________________

WHERE ___________________________________________________________

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]

GCSE Computer Science (9-1) - J277 8


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-1)

(b) Write an algorithm for the program. Remember that it will need to make
use of basic file handling operations. [6]

GCSE Computer Science (9-1) - J277 9


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B 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 ____________________ or _________________ 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

3601 Invalid

GCSE Computer Science (9-1) - J277 10


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B 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 ______________________________________________________

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

GCSE Computer Science (9-1) - J277 11


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B 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.

GCSE Computer Science (9-1) - J277 12


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-1)

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

(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

print(x)

GCSE Computer Science (9-1) - J277 13


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-1)

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

GCSE Computer Science (9-1) - J277 14


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited
Sample Question Paper 2B Mark Scheme
OCR GCSE Computer Science (9-1)

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

(b) Explain the difference between the == operator and the = operator. [2]

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

GCSE Computer Science (9-1) - J277 15


Protected by copyright and for use in accordance with the terms of the licence © 2020 PG Online Limited

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy