Skip to content

Course home

Data structures

Data structures

EasyMedium
12345678910111213
Question 10

A game developer is writing a Python script to populate a 4×44 \times 44×4 2D array representing a terrain elevation map. Each cell in the grid represents the height at a specific grid coordinate and is assigned a value returned by the function sample_elevation().

Complete the Python program in the code block below by filling in the five gaps on lines 9, 12, 14, and 16 so that the 2D array is correctly populated.

1  terrain_map = [ [0.0, 0.0, 0.0, 0.0],
2                  [0.0, 0.0, 0.0, 0.0],
3                  [0.0, 0.0, 0.0, 0.0],
4                  [0.0, 0.0, 0.0, 0.0] ]
5
6  y = 0
7  while y < 4:
8
9      x = _____
10     while x < 4:
11
12         terrain_map[ _____ ][ _____ ] = sample_elevation()
13
14         _____
15
16     _____
[4]
Markscheme

Data structures Questions

  1. GCSE
  2. /Computer Science
  3. /Data structures

36 exam-style questions on AQA GCSE Computer Science Data structures. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank