DoAssignment study guide
A1.6 · One-Dimensional Arrays, Indexes and Updates
Learn to create and update one-dimensional arrays in a program through clear examples and targeted practice.
Ontario Grade 11 Computer Science
Programming Concepts and Skills
ICS3U study topic A1.6
What you will learn
- Explain how a one-dimensional array stores related values in a sequence.
- Create an array and identify the index used to refer to each item.
- Update an item at a chosen index and describe how the array changes.
- Trace short Python 3 examples to determine the array state and displayed output.
1. What a one-dimensional array represents
- An array stores a sequence of related values under one variable name.
- A one-dimensional array has one sequence of positions.
- Python 3 list indexes begin at 0.
2. Create an array and read its items
- Square brackets create a Python list, and commas separate its items.
- An index selects one item from the array.
- The index of the last item in a non-empty Python list is one less than its length.
3. Update an item
- An indexed assignment replaces the value at that position.
- Updating one item leaves the other positions unchanged.
- Use an index that refers to an existing item.
4. Add an item and check the new state
- Python's append operation adds one item at the end of a list.
- Appending preserves the earlier items and increases the length by one.
- Trace the array before and after each update.
Trace for replacing a reading
| Point in the program | Index 0 | Index 1 | Index 2 | Index 3 |
|---|---|---|---|---|
| Before assignment | 17 | 18 | 20 | 21 |
| After readings[2] = 19 | 17 | 18 | 19 | 21 |
Trace for appending a supply
| Point in the program | Index 0 | Index 1 | Index 2 | Index 3 |
|---|---|---|---|---|
| Before append | pencil | ruler | eraser | not present |
| After append | pencil | ruler | eraser | notebook |
Worked example
Create and select an item
Python indexes are zero-based; each cell shows one list item.
Python 3
clubs = ["Art", "Robotics", "Music"]
print(clubs[1])- Identify the inputThe program uses the three names written in the list. No values are entered by a user.
- Trace the indexPython indexes start at 0. Art is at index 0, Robotics is at index 1, and Music is at index 2.
- Determine the outputThe print statement selects clubs[1], so the displayed value is Robotics.
Worked example
Replace one existing value
The value at index 2 has been replaced; the other values are unchanged.
Python 3
readings = [17, 18, 20, 21]
readings[2] = 19
print(readings)- Read the initial stateThe array begins with 17 at index 0, 18 at index 1, 20 at index 2, and 21 at index 3.
- Apply the updateThe assignment to readings[2] replaces 20 with 19. The values at indexes 0, 1, and 3 are not assigned new values, so they remain unchanged.
- Determine the outputThe print statement displays the updated list in its original order, with 19 in the third position.
Worked example
Append an item
The new item is at the end, after the three original items.
Python 3
supplies = ["pencil", "ruler", "eraser"]
supplies.append("notebook")
print(supplies)- Read the starting stateThe list contains three items. Their indexes are 0 for pencil, 1 for ruler, and 2 for eraser.
- Add the new itemThe append operation puts notebook after eraser. The original three items stay in the same positions, and notebook receives index 3.
- Determine the outputThe print statement displays all four items in order, including the new final item.
Common mistakes and how to avoid them
Lesson summary
- A one-dimensional array is a sequence of related values held under one variable name.
- In Python 3, square brackets create a list, and indexes start at 0.
- An indexed assignment replaces the value at that position.
- The append operation adds a value at the end of a Python list.
- Trace each change to check which values stay the same and which value or position changes.
Check your understanding
Question 1
- 0
- 1
- The number of items in the list
- correctIndex
Show answer and explanation
Question 2
- The first item is replaced.
- The second item is replaced.
- The third item is replaced.
- correctIndex
Show answer and explanation
Question 3
- One
- Two
- Three
- correctIndex
Show answer and explanation
Key terms
- One-dimensional array
- A sequence of related values arranged in one line of positions.
- Index
- A number used to identify an item's position in an array.
- Update
- A change to an array, such as replacing a value or adding an item.
- Python list
- A Python 3 sequence written using square brackets; it can represent a one-dimensional array in these examples.
Continue through ICS3U
View the complete ICS3U Ontario Grade 11 Computer Science curriculum and lessons
- A1.5 · Explain one-dimensional arrays, indexes, and bounds
- A2.1 · Write a program with input, processing, and output
- A1.1 · Use variables and constants with appropriate data types
- A1.2 · Explain binary, hexadecimal, and character encoding
- A1.3 · Use arithmetic and string assignment statements
- A1.4 · Use Boolean, comparison, and arithmetic operators correctly
About this lesson and its review
Published by DoAssignment. This reviewed lesson follows Ontario Grade 11 Computer Science (ICS3U), expectation A1.6. It is a study resource, not an official curriculum publication.
Before publication, content is checked for structure, mathematical or chemical notation, calculations, course boundaries, and readability. Errors can still occur, so corrections are welcomed.