Skip to content

Course home

Data structures

Data structures

EasyMedium
12345678910111213
Question 2

An agricultural engineer is writing a Python program to populate a 4×4 4 \times 4\,4×4 2D array representing a grid of soil moisture readings. Each cell in the grid is filled with a moisture value returned by the function get_moisture().

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 array is correctly populated.

1  moisture_grid = [ [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         moisture_grid[ _____ ][ _____ ] = get_moisture()
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