Skip to content
Menu

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

Lists (arrays)

Storing many values in one variable using Python lists: creating lists, indexing, changing items, append and remove, len(), looping through a list, and finding totals, maximums and averages.

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

Whiteboard video lesson: Lists (arrays)

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

  • Create and index a list
  • Add, change and remove items
  • Loop through a list
  • Calculate total, maximum and average

The method

  1. A list stores many values: scores = [5, 8, 2].
  2. Indexes start at 0: scores[0] is 5.
  3. append() adds to the end; remove() deletes a value.
  4. Loop with for item in list, or for i in range(len(list)).

Key words: list, array, element, index, append.

Worked examples

Worked examples from the lesson, with every step.

Question 1

nums = [4, 9, 2, 7]. What is nums[1] + nums[3]?

  1. Step 1: nums[1] = 9; nums[3] = 7
  2. Step 2: 9 + 7 = 16

Answer: 16

Question 2

What is in the list after this code? c:pets = ["cat", "dog"] c:pets.append("fish") c:pets[0] = "rabbit"

  1. Step 1: ["cat", "dog", "fish"]
  2. Step 2: index 0 → "rabbit"

Answer: ["rabbit", "dog", "fish"]

Question 3

Find the total and average of [6, 8, 10].

  1. Step 1: 6 + 8 + 10 = 24
  2. Step 2: 24 ÷ 3 = 8

Answer: total 24, average 8