Arrays and lists
Lesson details
Learning outcome
I can describe the differences between lists and arrays and use a list in a program.
Key learning points
- Data structures are used to store data in an organised and accessible way.
- Data structures can be static or dynamic.
- Static data structures reserve memory locations for a set amount of data. Their size cannot change.
- Dynamic data structures are more flexible. The memory capacity is not fixed.
Keywords
Static - a data structure that has a fixed size in memory
Dynamic - a data structure that can grow or shrink to accommodate items
Array - a static data structure that contains items of the same data type
List - a dynamic data structure that can contain items of different data types
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.
Teacher tip
Some exam boards do not require a differentiation between list and arrays. Make sure you are clear what is needed to be learnt for the exam specification you are teaching
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.What will be the output of this program?
12word = "MOONLIGHT"
print(word.lower())Code colourWhen 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
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
Q2.What does the random.choice() function do?
Q3.What will be the output of this program?
12fruit = "Strawberry"
print(fruit[5:10].upper())Code colourWhen 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
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
Q4. is a way of joining strings using the + operator to make a new string.
Q5. is the process of checking an input meets certain requirements.
Q6.What must be included in a Python program to use the random module?
Assessment exit quiz
6 Questions
Q1.Which of the following is true about arrays?
Q2.What is the correct way to create a list in Python?
Q3.In Python, the index of the first item in a list starts at .
Q4.Which of the following methods allows you to pick a random planet from the list planets?
Q5.Lists are data structures, meaning they can have items added or removed and can store different data types in the same list.
Q6.Arrays are data structures, meaning they cannot have items added or removed and they must contain items of the same data type.
To help you plan your 10 computer science lesson on: Arrays and lists, download all teaching resources for free and adapt to suit your pupils' needs...
To help you plan your 10 computer science lesson on: Arrays and lists, 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 4 computer science lessons from the Programming: strings and lists unit, dive into the full secondary computer science curriculum, or learn more about lesson planning.