Oxford Cambridge and RSA
GCSE (9-1) Computer Science
Algorithms & Programming
J277/02
Topic: Arrays & Data Structures
Time allowed: 45 minutes
Centre number Candidate number
First name Last name
INSTRUCTIONS INFORMATION
Turn over
Section A: Core Concepts & Indexing
1
A program uses a list (1D array) called scores to store the test results of 5 students: [10, 50, 60, 20, 90].
Fill in the missing Python / OCR Reference Language keywords to calculate the total.
total = 0 for i = 0 to ......................... - 1 total = total + scores[.........................] next i print(total)
[2]
2
Explain two benefits of using an Array to store 100 student names compared to creating 100 separate variables (e.g., name1, name2...).
[2]
3
A 2D array named seating_plan stores the names of students in a classroom. The array is indexed as seating_plan[row, column].
Col 0Col 1Col 2
Row 0"Ali""Bea""Caz"
Row 1"Dan""Eve""Fay"

(a) State the data stored at seating_plan[1, 0].
[1]

(b) State the data stored at seating_plan[0, 2].
[1]

(c) A student writes print(seating_plan[2, 0]). State what will happen and explain why.
[2]
Turn over
Section B: Debugging & Tracing
4
A developer is using a 2D array called stock to emulate a database table of products.
  • Column 0: Product Name (String)
  • Column 1: Price (Real)
  • Column 2: Quantity (Integer)
Current Data in stock: [ ["Apple", 0.50, 100], ["Banana", 0.30, 150], ["Pear", 0.40, 80] ]

The programmer wants to reduce the Quantity of "Apples" by 1. They write:
stock[0, 1] = stock[0, 1] - 1
(a) Identify the Logic Error in this line of code.
[1]

(b) Write the corrected line of code.
[1]
5
Trace the following algorithm which uses a 2D array named grid.
grid = [ [1, 2], [3, 4] ]
total = 0 for r = 0 to 1 for c = 0 to 1 if grid[r, c] > 2 then total = total + grid[r, c] else total = total - 1 endif next c next r print(total)
[4]
r c grid[r, c] total
001-1
Turn over
Section C: Coding & Application
6
A student writes a program to store phone numbers in an array.
contacts = [07700900123, 07700900456, 07700900789]
When they print the numbers, the leading zeros are missing (e.g., 7700900123).

(a) Explain why the leading zeros have been removed.
[1]

(b) Rewrite the array declaration so the leading zeros are preserved.
[1]
7
A teacher stores marks for 3 tests for 4 students in a 2D array called marks.
Rows represent Students (0 to 3). Columns represent Tests (0 to 2).
Example Data:
Test0Test1Test2
Stu0102030
Stu1505050
Stu2555
Stu31009080

Write an algorithm (in Python or OCR Reference Language) that:
  • Asks the user to input a Student ID (0-3).
  • Calculates the average score for that specific student across their 3 tests.
  • Outputs the average.
[6]
8
Write an algorithm to search the whole marks array (from Question 7) to find if any student scored 100 in any test.
  • If 100 is found, output "Found".
  • If the loops finish and 100 was never found, output "Not Found".
[6]
END OF QUESTION PAPER