New
New
Lesson 6 of 9
  • Year 10
  • AQA

2D arrays and lists

I can define and use two-dimensional lists.

Lesson 6 of 9
New
New
  • Year 10
  • AQA

2D arrays and lists

I can define and use two-dimensional lists.

These resources were made for remote use during the pandemic, not classroom teaching.

Switch to our new teaching resources now - designed by teachers and leading subject experts, and tested in classrooms.

Lesson details

Key learning points

  1. A list is used to hold multiple elements under one name.
  2. A two-dimensional list allows you to hold a list as one element.
  3. Data in a 2D list can be held in rows and columns.

Keywords

  • List - a dynamic data structure that can contain items of different data types

  • Two-dimensional - describes a list or array that has both columns and rows of values

  • Array - a static data structure that contains items of the same data type

Common misconception

Arrays and lists behave in the same way.

An array has a predefined fixed size. A list can vary in size throughout program execution.


To help you plan your year 10 computer science lesson on: 2D arrays and lists, download all teaching resources for free and adapt to suit your pupils' needs...

Indexing in 2D lists can be difficult for pupils to understand. Perhaps draw a table with index values in a grid so students can become familiar with the indexing of the rows and columns.
Teacher tip

Equipment

Pupils will need access to a device that can edit and run Python programs. Examples in this lesson use the RPF Code Editor https://oak.link/python-editor

Licence

This content is © Oak National Academy Limited (2025), licensed on Open Government Licence version 3.0 except where otherwise stated. See Oak's terms & conditions (Collection 2).

Lesson video

Loading...

Prior knowledge starter quiz

Download quiz pdf

6 Questions

Q1.
What does this code do?
123
animals = ["dog", "cat", "rabbit"] animals.insert(1, "hamster") print(animals)
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords

adds hamster to the end of the list
replaces cat with hamster
Correct answer: inserts hamster at index position `[1]`, shifting the other items
inserts hamster at index position [0], replacing dog

Q2.
What will be the output of the following code?
12
colors = ["red", "blue", "green", "blue"] print(colors.count("blue"))
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords

0
1
Correct answer: 2
3

Q3.
Which method would you use to add an item to the end of a list?

insert()
Correct answer: `append()`
pop()
remove()

Q4.
What does the pop() method do in a Python list?

adds an item to the end of the list
Correct answer: removes an item at a given index and returns it
replaces an item at a given index

Q5.
What is the correct way to remove "apple" from the following list?
1
fruits = ["banana", "apple", "cherry"]
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords

fruits.pop("apple")
Correct answer: `fruits.remove("apple")`
fruits.delete("apple")
fruits.cut("apple")

Q6.
A can return multiple values by placing them in a list.

Correct Answer: function

Assessment exit quiz

Download quiz pdf

6 Questions

Q1.
What is a two-dimensional (2D) list?

a list that can only store numbers
Correct answer: a list that contains multiple one-dimensional lists inside it
a list that is always empty
a list that can only store text

Q2.
How do you access the value at row index 1 and column index 2 in the following 2D list?
1234
grades = [ ["Math", "Science", "History"], [85, 90, 78] ]
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords

grades(1,2)
grades[2][1]
Correct answer: `grades[1][2]`
grades[1,2]

Q3.
Which of the following correctly defines a 2D list in Python?

Correct answer: `data = [ [1, 2, 3] , [4, 5, 6] ]`
data = ( [1, 2, 3] , [4, 5, 6] )
data = { [1, 2, 3] , [4, 5, 6] }
data = < [1, 2, 3] , [4, 5, 6] >

Q4.
What will be the output of the following code?
12345
table = [ ["apple", "banana", "cherry"], [3, 2, 5] ] print(table[0][1])
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords

apple
Correct answer: banana
2
3

Q5.
The () method can be used to add a new row to a 2D list.

Correct Answer: append, append()

Q6.
How can you change the value "dog" to "cat" in the following 2D list?
1234
animals = [ ["lion", "tiger", "dog"], ["parrot", "eagle", "owl"] ]
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords

Correct answer: `animals[0][2] = "cat"`
animals[1][2] = "cat"
animals[2][0] = "cat"
animals[0][1] = "cat"