Back to Arrays
N
Oak National Academy
Lessons written by expert teachers in England, each with slides, a video and quizzes.
Their topic:
Programming: strings and lists · Algorithms
For your topic:
Arrays · Computer Science (9-1) - 0984
Use these lessons alongside our lesson note, which covers your syllabus in full.
What this covers in your syllabus
3 lessons from Oak National Academy
1
2D arrays and lists
2
Arrays and lists
3
Data structures
Lesson 1 of 3 · GCSE level, ages 14 to 16
2D arrays and lists
By the end:
I can define and use two-dimensional lists.
Key learning points
A list is used to hold multiple elements under one name.
A two-dimensional list allows you to hold a list as one element.
Data in a 2D list can be held in rows and columns.
Keywords
list
a dynamic data structure that can contain items of different data types
two-dimensional
describes a list or array that has both columns and rows of values
array
a static data structure that contains items of the same data type
A common mistake
Mistake: Arrays and lists behave in the same way.
In fact: An array has a predefined fixed size. A list can vary in size throughout program execution.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
What is a two-dimensional (2D) list?
a list that can only store numbers
a list that contains multiple one-dimensional lists inside it
a list that is always empty
a list that can only store text
How do you access the value at row index 1 and column index 2 in the following 2D list? ```grades = [ ["Math", "Science", "History"], [85, 90, 78] ]```
`grades(1,2)`
`grades[2][1]`
`grades[1][2]`
`grades[1,2]`
Which of the following correctly defines a 2D list in Python?
`data = [ [1, 2, 3] , [4, 5, 6] ]`
`data = ( [1, 2, 3] , [4, 5, 6] )`
`data = { [1, 2, 3] , [4, 5, 6] }`
`data = < [1, 2, 3] , [4, 5, 6] >`
What will be the output of the following code? ```table = [ ["apple", "banana", "cherry"], [3, 2, 5] ] print(table[0][1])```
apple
banana
2
3
How can you change the value "dog" to "cat" in the following 2D list? ```animals = [ ["lion", "tiger", "dog"], ["parrot", "eagle", "owl"] ]```
`animals[0][2] = "cat"`
`animals[1][2] = "cat"`
`animals[2][0] = "cat"`
`animals[0][1] = "cat"`
Check answers
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.
Read the licence
Lesson 2 of 3 · GCSE level, ages 14 to 16
Arrays and lists
By the end:
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
A common mistake
Mistake: Arrays and lists behave in the same way.
In fact: An array has a predefined fixed size. A list can vary in size throughout program execution.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
Which of the following is true about arrays?
Arrays are dynamic data structures that allow adding and deleting items.
Arrays store items of different data types.
The size of an array is fixed, and items must all be of the same type.
Arrays can grow or shrink in size as needed.
What is the correct way to create a list in Python?
`planets = ("Mercury", "Venus", "Earth")`
`planets = ["Mercury", "Venus", "Earth"]`
`planets = {Mercury, Venus, Earth}`
`planets = "Mercury", "Venus", "Earth"`
Which of the following methods allows you to pick a random planet from the list planets?
`random.select(planets)`
`random.choice(planets)`
`random.shuffle(planets)`
Check answers
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.
Read the licence
Lesson 3 of 3 · GCSE level, ages 14 to 16
Data structures
By the end:
I can describe and compare data structures.
Key learning points
Data structures are used to help store, organise and manipulate data to solve problems efficiently.
Arrays are static data structures that can store data of a single type in indexed elements.
Lists are dynamic data structures that can store data of different types in indexed elements.
The choice of data structure depends on the specific needs of the algorithm or problem.
Keywords
data structure
a way of organising and storing data in a computer
composite
something made of various parts or elements
dynamic data structure
a data structure where the size and memory allocation can change as a program runs
static data structure
a data structure with a fixed size and memory allocation that is set before a program runs
A common mistake
Mistake: Arrays are always the best choice for storing and accessing collections of data.
In fact: While arrays offer efficient direct access to elements using their index, they have limitations, such as fixed size and potential inefficiency in terms of unused elements.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
What is a data structure?
a way to organise and store data in a computer
a type of programming language
a tool used to debug programs
a method for writing algorithms
What is a static data structure?
a structure that only stores numerical data
a structure that is independent of memory allocation
a structure with a size that can change during program execution
a structure with a fixed size and memory allocation
What is a dynamic data structure?
a structure that stores only one type of data
a structure with a fixed size
a structure that can change in size during program execution
a structure that does not use memory
Which of the following is an example of a static data structure?
list
array
dynamic array
linked list
Check answers
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.
Read the licence
The wording comes from each publisher. The layout and the links to your syllabus are ours.