Arrays and Lists in Programs
This GCSE computing lesson explores Arrays and Lists in Programming. Students store and process collections of data, use indexes and iteration and apply one- and two-dimensional structures to common programming tasks. It supports KS4 classroom teaching, independent study and exam revision using clear, subject-specific vocabulary.
Arrays and Lists in Programs
This GCSE computing lesson explores Arrays and Lists in Programming. Students store and process collections of data, use indexes and iteration and apply one- and two-dimensional structures to common programming tasks. It supports KS4 classroom teaching, independent study and exam revision using clear, subject-specific vocabulary.
Arrays, KS4 Computer Science, GCSE Computer Science, Data Structures, 1D Arrays, 2D Arrays, Array Indexing, Element Access, Array Traversal, Lists, Data Storage, Programming Fundamentals, MCQs, Open Questions, Polls, Emoji Polls, Exit Tickets
Learning goal
I can understand how arrays and lists store multiple values in programming, and choose and use them appropriately in simple programs.
Deze slide heeft geen instructies
What are some things you already know about arrays and lists?
Use this to surface prior ideas such as data, items, index, shopping list, scores, variables, organise, add and remove. Pick out misconceptions too, especially if students mix up a single value with a collection.
One value or many values?
A scalar variable stores one value at a time
Examples: one score, one name, one price
A collection stores a group of related values
Examples: several scores, class names, shopping items
Arrays and lists are ways to store these collections
Keep the term scalar variable simple: a normal variable holding a single item such as an integer or string.
Why not use lots of variables?
`score1`, `score2`, `score3` quickly become messy
Repeating code is harder to read and maintain
It is difficult to process all values in a consistent way
Arrays and lists keep related data together
A useful contrast is that separate variables work for a tiny amount of data, but they do not scale well when the program needs loops, searching or updates across many items.
What arrays and lists do
Arrays and lists are data structures that store multiple related items under one variable name. Each item has a position, so the program can access a specific value when needed.
Stress that the values are usually related by purpose: scores, names, shopping items, temperatures, and so on.
Everyday examples
A list of test scores
A list of student names
A shopping list in an app
One program variable can hold the whole collection
Link the examples to the later code operations: find an item, change an item, add an item, remove an item.
Fixed size and dynamic size
An array usually has a fixed size
A list can usually grow or shrink as needed
Fixed size suits data where the number of items is known
Dynamic size suits data where items may be added or removed
At this level, 'usually' is important because languages differ. Keep the comparison conceptual rather than language-specific.
Why are arrays and lists useful in a program?
They store one value
They hide all data
They group related items
They remove all loops
Checks the central idea from slides 2 to 6: collections keep related data together under one variable name. Distractors target confusion with scalar variables and exaggerated claims about what collections do.
Complete the summary
A scalar variable stores one value, but a collection stores related items together. Arrays and lists help to organise data more clearly in a program.
The blanks focus on the key contrast and purpose introduced in the first subtopic.
When an array is useful
Good when the number of items stays the same
Each position is planned in advance
Example: scores for 30 questions
The structure stays stable while values may change
Emphasise that fixed size does not mean fixed values. The values can change; the number of spaces is what stays fixed.
When a list is useful
Good when the number of items can change
Items may be added during the program
Items may also be removed
Example: a shopping basket or to-do list
Students often recognise lists from apps. Use that familiarity to make the dynamic idea concrete.
Choosing between them
Choose an array when the number of values is known and fixed. Choose a list when the collection needs to change size during the program. In both cases, the aim is to organise related data clearly.
This is the key decision slide for the learning goal. Keep bringing the choice back to program needs, not memorised definitions.
Which situation is best for a list?
Scores for 30 questions
Months of the year
A fixed seat plan
A shopping basket
Tests choosing between fixed and dynamic size. The correct answer is the changing collection; the distractors are all fixed-size cases discussed or implied by the content.
Which feature matters most when choosing array or list?
Fixed size
Can grow
Known length
Add or remove
Deze slide heeft geen instructies
Counting positions from zero
Items are stored in positions called indexes
In many programming languages, counting starts at 0
First item → index `0`
Second item → index `1`
Third item → index `2`
Flag the common misconception that the first item should be index 1. This is one of the main stumbling points.
Index and value
Index = the position
Value = the item stored there
Example: in `[12, 18, 9]`, index `1` stores `18`
Make sure students do not confuse the value with its position. Ask the teacher to point out that 18 is not 'item 18'; it is the value at position 1.
Accessing an element
Use the index to read one item from the collection
Example: `scores[0]` means the first score
Example: `names[2]` means the third name
The collection name stays the same; the index picks the item
You can mention that square brackets are common notation, though exact syntax differs between languages.
Updating an element
A value at a chosen index can be changed
Example: `scores[1] = 20`
This replaces the old value at index `1`
The rest of the collection stays the same
Useful misconception check: updating one element does not create a new collection name; it changes one stored value in the existing structure.
Iterating through all elements
Iterating means going through items one by one
This is often done with a loop
A loop can print every name or total every score
Collections make repeated processing much easier
No need for full code here unless the teacher wishes. The key idea is that collections work well with loops because the items are organised by position.
A simple program pattern
Store related values in one collection
Use indexes to access or update items
Use a loop to process every item
This keeps code shorter and clearer
This slide ties indexing and iteration together into one programming workflow.
In [12, 18, 9], what is at index 1?
12
18
9
1
Targets the common confusion between position and value, and reinforces counting from zero.
Complete the programming idea
In many languages, counting starts at 0. An index is the position of an item, and a loop can iterate through the whole collection one by one.
Reinforces three load-bearing terms from slides 10 to 15: zero-based counting, index and iterate.
Why is a loop useful with a collection?
Expected elements: a collection lets the program use one variable name for many related values, then access items by index and process all items with a loop. Strong answers may mention clearer code or easier updates.
Adding items
Lists can usually add new items easily
This is useful when data arrives during the program
Example: adding a new shopping item
Arrays are less flexible because their size is fixed
Keep this at a conceptual level: students do not need language-specific method names unless their class language requires them.
Removing items
Lists can also remove items
Example: deleting a completed task from a to-do list
This changes the size of the collection
That is why lists suit changing data
If helpful, note that after removal, positions may shift. This supports the idea that index depends on order.
Searching for a value
Searching means checking whether a value is in the collection
Example: is `"Alex"` in the names list?
A program may check items one by one
Collections make searching possible within one organised structure
You can connect this to iteration: many simple searches work by looping through the collection until the value is found.
Example: scores
Store all scores together
Find one score by index
Update a score if corrected
Loop through scores to find a total or highest value
This is a good example because it naturally uses access, update and iteration without needing advanced code.
Example: names
Store a group of names in order
Access one name by index
Search to check whether a name is present
Useful for registers, teams or contact lists
Deze slide heeft geen instructies
Example: shopping items
A shopping list often changes size
Items are added and removed regularly
That makes a list a strong choice
The data stays organised in one place
This is the clearest everyday example for dynamic size, so use it to reinforce why lists are useful.
Why collections help programs
They organise related data clearly
They reduce repeated variable names
They work well with loops and searching
They make programs easier to update and maintain
This slide resolves the central question: arrays and lists are useful because they let programs handle groups of related values efficiently and clearly.
Which operation usually changes the size of a list?
Updating an item
Reading by index
Adding an item
Finding a value
Checks understanding of list operations from slides 16 to 22. Updating and searching use the collection without changing its size.
Complete the summary of operations
A shopping list can grow when items are added and shrink when items are removed. Collections also help with searching and make programs easier to maintain.
Echoes the everyday examples and the final usefulness slide without introducing new contexts.
When would you choose a list instead of an array?
Discussion points: choose an array when the number of items is known and fixed; choose a list when items may be added or removed. Students may use examples such as test scores, names or shopping items.
Do you feel more confident in your understanding of arrays and lists?
Deze slide heeft geen instructies
Glossary
scalar variable - a variable that stores one value
collection - a group of related values stored together
array - a collection with a fixed size
list - a collection that can usually grow or shrink
index - the position of an item in a collection
element - one item stored in an array or list
iterate - to go through items one by one
Deze slide heeft geen instructies