Python list operations
Lesson details
Learning outcome
I can add and remove items and sort data held in a list.
Key learning points
- List methods can be used to perform operations on lists such as to add, remove and insert items.
- A list is a dynamic data structure, meaning the length of a list is the number of values it currently stores.
- 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 - arranging data into a meaningful 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.
Teacher tip
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.
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
Lesson video
Loading...
Prior knowledge starter quiz
6 Questions
Q1. is used when there is more than one possible path for a program to follow.
Q2.Match the keyword to the definition.
used when there is more than one possible path for a program to follow
a collection of data in a particular sequence
an organised way to store data for easy use
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?
Q4.What letter can you type in to join text and the values held by a variable in a print statement?
Q5.What is an IndexError?
Q6.A list is a d data structure that can grow or shrink as you add or remove items.
Assessment exit quiz
4 Questions
Q1.Which list method can be used to add an item to the end of a list?
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?
Q3.The operation `list.sort(reverse=True)` sorts a list in order
Q4.What list method is used to find the index of a specific item?
To help you plan your 9 computing lesson on: Python list operations, download all teaching resources for free and adapt to suit your pupils' needs...
To help you plan your 9 computing lesson on: Python list operations, download all teaching resources for free and adapt to suit your pupils' needs.
The starter quiz will activate and check your pupils' prior knowledge, with versions available both with and without answers in PDF format.
We use learning cycles to break down learning into key concepts or ideas linked to the learning outcome. Each learning cycle features explanations with checks for understanding and practice tasks with feedback. All of this is found in our slide decks, ready for you to download and edit. The practice tasks are also available as printable worksheets and some lessons have additional materials with extra material you might need for teaching the lesson.
The assessment exit quiz will test your pupils' understanding of the key learning points.
Our video is a tool for planning, showing how other teachers might teach the lesson, offering helpful tips, modelled explanations and inspiration for your own delivery in the classroom. Plus, you can set it as homework or revision for pupils and keep their learning on track by sharing an online pupil version of this lesson.
Explore more key stage 3 computing lessons from the Python programming with sequences of data unit, dive into the full secondary computing curriculum, or learn more about lesson planning.