Oxford Cambridge and RSA
GCSE (9-1) Computer Science
Algorithms & Programming
J277/02
Topic: Data Representation & Programming Constructs
Time allowed: 45 minutes
Centre number Candidate number
First name Last name
INSTRUCTIONS INFORMATION
Turn over
Section A: Low-Frequency "Ghost Topics"
1
A programmer uses a local variable temp inside a function called calculateAverage().

(a) State what is meant by the 'scope' of a variable.
[1]

(b) Explain two advantages of using local variables rather than global variables.
[4]
2
The J277 specification requires the use of records to store data.
A car dealership uses a record structure called Car to store data about vehicles.
The fields are: ID (Integer), Make (String), and Price (Real).

(a) Write the OCR Exam Reference Language (ERL) or Python-style code to define this record structure.
[3]

(b) An array called showroom stores 50 Car records.
Write a line of code to update the Price of the car at index 5 to 12500.00.
[2]
3
The function ASC() returns the ASCII value of a character.
The function CHR() returns the character for a given ASCII value.
  • ASC("A") is 65
  • ASC("B") is 66
State the output of the following lines of code:
[3]
print(CHR(67))
print(ASC("D"))
print(CHR(ASC("A") + 3))
Turn over
4
Complete the table to show the result of each string operation on the string:
phrase = "Computer Science"
[4]
Operation Result
phrase.length
phrase.substring(0, 8)
phrase.left(3)
phrase.upper
5
The Character data type is a single unit of a Character Set.

(a) State the difference between the ASCII character set and the Unicode character set.
[2]

(b) Explain why a programmer might choose Unicode over ASCII despite Unicode using more storage space.
[2]
Section B: High-Frequency Baseline Skills
6
The following code asks a user for a number and adds 10 to it. It contains a Runtime Error.
num = input("Enter a number: ") total = num + 10 print(total)
(a) Identify the error in this code.
[1]

(b) Rewrite the first line to fix the error using casting.
[1]
Turn over
7
A central heating system turns on if the isCold variable is True AND the timerActive variable is True.
Complete the truth table for the logic: isCold AND timerActive.
[4]
isCold timerActive Output
False False
False True
True False
True True
8
State the value and the Data Type of the variable result in each instance:
[4]
result = 10 / 4
Value: ....................................................... Data Type: .......................................................
result = 10 DIV 4
Value: ....................................................... Data Type: .......................................................
9
A library system needs to store the following data. State the most appropriate data type for each:
[4]
The number of pages in a book:
The price of a late fine:
Whether the book is currently on loan:
The ISBN (e.g., "978-3-16-148410-0"):
10
State one reason why a programmer would use a constant (e.g., CONST VAT = 0.2) instead of a variable.
[2]
END OF QUESTION PAPER