New
New
Year 9

Creating lists in Python

I can create a list in Python and use selection to access and display list items.

Link copied to clipboard

New
New
Year 9

Creating lists in Python

I can create a list in Python and use selection to access and display list items.

Link copied to clipboard

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.

These resources were created for remote use during the pandemic and are not designed for classroom teaching.

Lesson details

Key learning points

  1. Lists are data structures that can store multiple related items in Python.
  2. Values held in a list are ordered by index number, with the first item in the list being stored at index [0].
  3. List items can be directly accessed by specifying the index value.

Keywords

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

  • List - a collection of data in a particular sequence

  • Data structure - an organised way to store data for easy use

  • Index - the location of an item or element in a list or string

Common misconception

A list index starts at 1 as that is the first element in the list and should be counted as the first item.

In most programming languages, list indexing is zero-based, which means the index starts at 0. The number indicates the position before the value is seen.


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

Use the starter code to live model what happens when different index values are used to reference a list. It is important for pupils to see that errors can occur and why they have happened. Explain what the error messages are saying so that actions to debug become obvious.
Teacher tip

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.

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.
In Python, which keyword allows you to create a block of code that only executes when a certain condition is true?
Correct Answer: if
Q2.
Which
if
statement would correctly check if the variable score is greater than or equal to 80?
Correct answer: `if score >= 80:`
if score > 80:
if score = 80:
if score <= 80:
Q3.
Which of the following is correct when describing nested
if
statements?
The first condition needs to be
False
before the next condition can be run.
Correct answer: The first condition needs to be `True` before the next condition can be run.
Q4.
The
=
symbol in Python is used for ...
equations.
Correct answer: assignment.
comparison.
Q5.
What keyword is used in Python to output text to the user?
Correct Answer: print, print()
Q6.
S is used when there is more than one possible path for a program to follow.
Correct Answer: Selection, election

6 Questions

Q1.
What is the purpose of an
elif
statement in Python?
to create a loop
to define a function
Correct answer: to handle multiple conditions in a selection statement
Q2.
What is the correct syntax for creating a list in Python?
{“Monday”, “Tuesday”, “Wednesday”}
Correct answer: [“Monday”, “Tuesday”, “Wednesday”]
(Monday, Tuesday, Wednesday)
Q3.
What type of data structure is a list in Python?
static
Correct answer: dynamic
Q4.
Each item within the list is referred to by an , which is its position in the list.
Correct Answer: index, index number
Q5.
What will the following code print?
1234
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print(days[3])
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
Wednesday
Correct answer: Thursday
IndexError
Tuesday
Q6.
What will the following code print?
1234
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print(days[7])
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
Saturday
Sunday
Correct answer: IndexError