Skip to content

Course home

Data structures

Data structures

EasyMedium
12345678910111213
Question 7

A programmer is writing a Python program to populate a 3x3 2D array representing a pixel art canvas. Each cell in the grid is filled with a color returned by the function get_color().

Complete the Python program in the code block below by filling in the five gaps on lines 8, 11, 13, and 15 so that the array is correctly populated.

1  grid = [ ["", "", ""],
2           ["", "", ""],
3           ["", "", ""] ]
4
5  r = 0
6  while r < 3:
7
8      c = _____
9      while c < 3:
10
11         grid[ _____ ][ _____ ] = get_color()
12
13         _____
14
15     _____
[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