← VCE Data Analytics U3O2

One-dimensional arrays

A single row of items of the same data type, stored under one name. Each item is found by its index number, starting at 0. In Python, a list is used as an array.

Understanding One-dimensional arrays in VCE Data Analytics U3O2

What it does: scores[0] uses index 0 to get the first item in the array. All three elements are strings, so this list follows the array rule of one data type for every element. Indexes start at 0, so an array with 5 items uses indexes 0, 1, 2, 3 and 4. range(len(marks)) gives indexes 0 up to the last one. Adding 1 goes past the end and causes an IndexError. Square brackets are used to access an item by index. Round brackets would try to call prices as a function. Arrays are planned with a fixed number of elements. Python lists can change size, but when used as an array we treat the size as fixed.

Common mistakes: An array (list) element is found with square brackets, not round brackets. It should be print(scores[0]). The items in a Python list are separated by commas, not semicolons. It should be temps = [21, 25, 19, 30].

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 32–75) and word search (Modules 3–146).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which statement best describes a one-dimensional array?
A single row of items of the same data type, found by indexA table of rows and columns holding mixed data types
Matches
temps = [21, "warm", 19.5]
↓
The elements are different data types (integer, string, float). An array must hold one data type only.
Applying
Meanings
Term
one-dimensional array
Meaning
A single row of items of the same data type, stored under one name. Each item is found by its index number, starting at 0. In Python, a list is used as an array.
Practice
scores = [72, 85, 90, 64, 78]
Testing
Gaps
print(scores[])
Check Answer
Spots
1scores = [12, 15, 9, 20]
2print(scores(0))

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Hyena' badge — Savannah Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which statement best describes a one-dimensional array?
A. A single row of items of the same data type, found by index ✓
B. A table of rows and columns holding mixed data types
A one-dimensional array is a single row of items. Every item has the same data type and is found by its index number.
2. scores = [12, 18, 9, 15] What is scores[0]?
A. 18
B. 12 ✓
Index numbers start at 0, so scores[0] is the first item, which is 12.
3. Which list is a valid array of one data type?
A. temps = [21.5, 19.0, 23.4] ✓
B. temps = [21.5, "cold", True]
An array holds items of the same data type. The first list has only floats. The second mixes a float, a string and a Boolean.
4. An array called names has 5 items. What is the last valid index?
A. 5
B. 4 ✓
Indexes start at 0, so an array with 5 items uses indexes 0, 1, 2, 3 and 4.
5. Which loop visits every index of the array marks?
A. for i in range(len(marks)): ✓
B. for i in range(len(marks) + 1):
range(len(marks)) gives indexes 0 up to the last one. Adding 1 goes past the end and causes an IndexError.

Match the Pairs

scores = [12, 15, 9, 20] → Creates a one-dimensional array of four integers using a Python list
for i in range(len(scores)): → Loops through every index of the array, from 0 up to the last index
Each item in an array is found by its index number, and the first index is 0 → print(scores[0])
Every element in an array must be the same data type, such as all strings → names = ["Ava", "Liam", "Mia"]
temps = [21, "warm", 19.5] → The elements are different data types (integer, string, float). An array must hold one data type only.
nums = [4, 8, 6] print(nums[3]) → Index 3 does not exist. The array has 3 items, so the valid indexes are 0, 1 and 2.

Key Term

one-dimensional array
A single row of items of the same data type, stored under one name. Each item is found by its index number, starting at 0. In Python, a list is used as an array.

Fill in the Blanks

1. scores = [12, 18, 15, 20] print(scores[0])
Hint: Type the index number of the first item in the array
2. scores = [12, 18, 15, 20] for i in range(len(scores)): print(scores[i])
Hint: Type the function that generates every index number to loop through
3. scores = [12, 18, 15, 20] size = len(scores)
Hint: Type the function that gives the number of items in the array
4. scores = [12, 18, 15, 20] scores[2] = 99
Hint: Type the index of the third item, which is being replaced
5. scores = [12, 18, 15, 20] print(scores[len(scores) - 1])
Hint: Type the number to subtract from the size to reach the last index

Spot the Error

Question 1
A scores = [12, 15, 9, 20]
B print(scores(0))
C print(scores[3])
Line B — An array (list) element is found with square brackets, not round brackets. It should be print(scores[0]).
Question 2
A temps = [21; 25; 19; 30]
B for i in range(4):
C print(temps[i])
Line A — The items in a Python list are separated by commas, not semicolons. It should be temps = [21, 25, 19, 30].
Question 3
A marks = [70, 85, 90]
B for i in range(4):
C print(marks[i])
Line B — The array has 3 elements, so the valid indexes are 0, 1 and 2. range(4) would reach index 3 and cause an IndexError. It should be range(3).
Question 4
A prices = [4, 8, 6, 10]
B total = 0
C for i in range(4):
D total = total + price[i]
E print(total)
Line D — The array is called prices, not price, so this line would cause a NameError. It should be total = total + prices[i].
Question 5
A ages = [14, 'fifteen', 13, 16]
B print(ages[1])
C print(len(ages))
Line A — Every element of an array must have the same data type. 'fifteen' is a string mixed in with integers. It should be the integer 15.

Student with a class code? Join your class →