Skip to content
Menu

Year 10 (ages 14–15, Grade 9 in the US) · Computing · GCSE programming · Lesson 8

2D lists and records

Storing tables of data in two-dimensional lists, accessing items with [row][column], looping through rows and columns with nested loops, and using lists of records to keep related data together.

Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

Whiteboard video lesson: 2D lists and records

8-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Explain a 2D list
  • Access elements with [row][column]
  • Loop through a 2D list
  • Use records to store related data

The method

  1. A 2D list is a list of lists — like a table.
  2. grid[row][column]; both start at 0.
  3. Outer loop over rows; inner loop over columns.
  4. A record groups different fields about one thing.

Key words: 2D list, row, column, nested loop, record.

Worked examples

Worked examples from the lesson, with every step.

Question 1

grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. What is grid[2][0]?

  1. Step 1: [7, 8, 9]
  2. Step 2: 7

Answer: 7

Question 2

Same grid: what is grid[1][1] + grid[0][2]?

  1. Step 1: grid[1][1] = 5; grid[0][2] = 3
  2. Step 2: 5 + 3 = 8

Answer: 8

Question 3

Find the total of all values in grid.

  1. Step 1: 6 + 15 + 24
  2. Step 2: = 45

Answer: 45