icon-background-square
New
New
Year 9

Mathematical operations in data structures

I can perform a range of mathematical operations on list items and return a result.

icon-background-square
New
New
Year 9

Mathematical operations in data structures

I can perform a range of mathematical operations on list items and return a result.

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. Mathematical operations can be performed using operators in Python.
  2. Mathematical operations can be performed on individual list items.
  3. The shuffle() function can be used to randomly reorder the contents of a list.

Keywords

  • Operator - a symbol or word that instructs the computer to perform a specific calculation or action

  • List - a collection of data in a particular sequence

Common misconception

Mathematical operations cannot be performed on items held in a list; the items must first be stored in a new variable.

Mathematical operations can be performed directly on list items by using an index value to reference the value used.

Unplugged activites help to visualise tasks away from the computer screen. If you think pupils will struggle to understand the tasks, try rehersing them in groups with printed versions of the lists so that the effect of instructions can be visualised.
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.
What is a list in Python?
a single-value data type
a type of loop
a function to perform calculations
Correct answer: a collection of data in a particular sequence
Q2.
Match the terms with their definitions.
Correct Answer:string,a collection of characters
tick

a collection of characters

Correct Answer:mutable,able to be changed
tick

able to be changed

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

the location of an item in a list

Q3.
What is the index number that holds the first item in a Python list?
-1
Correct answer: 0
1
2
Q4.
What method would you use to add an item to a list?
remove()
sort()
Correct answer: `append()`
index()
Q5.
What is the term for repeating a sequence of instructions?
Correct Answer: iteration
Q6.
Which loop is used for count-controlled iteration?
Correct Answer: for, for loop

6 Questions

Q1.
Match the terms with their definitions.
Correct Answer:operator,a symbol or word that instructs the computer to perform a calculation
tick

a symbol or word that instructs the computer to perform a calculation

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

a collection of data in a sequence

Correct Answer:shuffle,randomly reorder the contents of a list
tick

randomly reorder the contents of a list

Correct Answer:string,a collection of characters
tick

a collection of characters

Correct Answer:immutable,not able to be changed
tick

not able to be changed

Q2.
What is the primary purpose of a for loop in Python?
to execute code indefinitely
Correct answer: to repeat a block of code a specific number of times
to handle errors in code
to define variables
Q3.
What is the index of the second item in a list?
Correct Answer: 1, one
Q4.
What can be used to perform calculations in Python?
variables
Correct answer: operators
loops
strings
Q5.
Which statement about performing mathematical operations on list items in Python is true?
Items must be copied to a new variable first.
Operations are only for lists with numbers.
Correct answer: Operations can be performed directly on list items.
Items need to be converted to strings for operations.
Q6.
What does the
shuffle()
function do to a list in Python?
sorts the list in ascending order
reverses the order of the list
Correct answer: randomly reorders the list items
removes duplicates from the list