SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
Edexcel 1CP2 · Topic 1 · 1.2i

Arrays
& Lists

Static Data Structures · 1D and 2D Arrays · List Operations

CSZoneEdexcel GCSE Computer Science 1CP2
Arrays

Fixed-Size Collections

An array is a data structure that stores a fixed number of items of the same data type in contiguous memory. Items are accessed using an index, starting at 0 in most languages.
scores = [90, 75, 88, 62, 95] # 1D array / list
print(scores[0]) # 90 (first item)
print(scores[4]) # 95 (last item)
scores[2] = 99 # update item at index 2
Arrays have a fixed size — cannot grow or shrink once declared (unlike lists in Python)
2D Arrays

Arrays of Arrays

A 2D array is a grid of values — like a spreadsheet table. Access items using two indices: [row][column].
grid = [[1, 2, 3],
        [4, 5, 6],
        [7, 8, 9]]

print(grid[0][1]) # 2 (row 0, column 1)
print(grid[2][2]) # 9 (row 2, column 2)
Uses: game boards, timetables, images (pixels)
Lists vs Arrays

Key Differences

Array: fixed size, same data type, fast access by index, stored in contiguous memory
Python list: dynamic size, can hold mixed types, supports append/remove/insert
names = []
names.append("Alice") # add to end
names.append("Bob")
names.remove("Alice") # remove item
print(len(names)) # 1
Exam Practice

Have a go at this question

Edexcel-style question
A list called temps stores temperature readings: [14, 22, 19, 31, 27]. Write Python code to output the third temperature and the total number of items in the list.
2 marks
print(temps[2]) # outputs 19 [1]
print(len(temps)) # outputs 5 [1]
Key Takeaways

What to Remember

Arrays: fixed size, same data type, indexed from 0
2D arrays: accessed with [row][col]; used for grids and tables
Python lists: dynamic; use append(), remove(), len()
First item is always at index 0, not 1