icon-background-square
New
New
Year 9

Python list operations

I can add and remove items and sort data held in a list.

icon-background-square
New
New
Year 9

Python list operations

I can add and remove items and sort data held in a list.

warning

These resources will be removed by end of Summer Term 2025.

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

Lesson details

Key learning points

  1. List methods can be used to perform operations on lists such as to add, remove and insert items.
  2. A list is a dynamic data structure, meaning the length of a list is the number of values it currently stores.
  3. A list can be sorted using a list method to aid processing.

Keywords

  • Append - adding to an existing data structure

  • Remove - taking an item away from an existing data structure

  • Sort - putting items in a particular order

  • List method - a built-in function that will perform an operation on a list

Common misconception

Once an item is added to a list it is fixed in to the structure of the list and it cannot be altered.

Items can be removed, inserted and amended in a list using list methods. These methods change the structure of the list. Values of items can also be updated.


To help you plan your year 9 computing lesson on: Python list operations, download all teaching resources for free and adapt to suit your pupils' needs...

List structures can be modelled using props. Playing cards are a good example as the cards can be arranged in order to visualise where the data is stored and in what order.
speech-bubble
Teacher tip
equipment-required

Equipment

All pupils require access to devices that can edit and run Python programs. Starter code files are available to copy or use directly via the Raspberry Pi Foundation's Code Editor.

copyright

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...

6 Questions

Q1.
is used when there is more than one possible path for a program to follow.
Correct Answer: selection
Q2.
Match the keyword to the definition.
Correct Answer:selection,used when there is more than one possible path for a program to follow
tick

used when there is more than one possible path for a program to follow

Correct Answer:list,a collection of data in a particular sequence
tick

a collection of data in a particular sequence

Correct Answer:data structure,an organised way to store data for easy use
tick

an organised way to store data for easy use

Correct Answer:index,the location of an item or element in a list or string
tick

the location of an item or element in a list or string

Q3.
What is the correct way to access the first item in a list called names?
Correct answer: `names[0]`
names[1]
names{0}
names(0)
names(1)
Q4.
What letter can you type in to join text and the values held by a variable in a print statement?
j
c
Correct answer: f
p
Q5.
What is an IndexError?
when you have too many items in a list
Correct answer: when you refer to an index that does not exist in a list
when you have too few items in a list
when you have two of the same index values in a list
Q6.
A list is a d data structure that can grow or shrink as you add or remove items.
Correct Answer: dynamic, ynamic

4 Questions

Q1.
Which list method can be used to add an item to the end of a list?
list.insert()
list.add()
Correct answer: `list.append()`
list.remove()
Q2.
Which list method can be used to remove the last item from a list if you do not know the index of the last item?
Correct answer: `list.pop()`
list.remove()
list.delete()
list.append()
Q3.
The operation `list.sort(reverse=True)` sorts a list in order
Correct Answer: descending
Q4.
What list method is used to find the index of a specific item?
list.find(item)
list.search(item)
Correct answer: `list.index(item)`
index.find(item)