DoAssignment study guide
A1.5 · Explain one-dimensional arrays, indexes, and bounds
Learn to explain one-dimensional arrays, indexes, and bounds through clear examples and targeted practice.
Ontario Grade 11 Computer Science
Programming Concepts and Skills
ICS3U study topic A1.5
What you will learn
- Explain how a one-dimensional array stores an ordered group of values.
- Explain how an index identifies a value's position in an array.
- Identify the valid index bounds and recognize an index that is outside them.
- Trace a short Python 3 example involving an array.
1. What an array represents
- A one-dimensional array is an ordered sequence of values.
- An index identifies a position; it is not the value stored there.
- The array's order matters because each value has a particular position.
2. Indexes and bounds
- Python 3 list indexes begin at 0.
- For a zero-based array with elements, the valid bounds are 0 and .
- The number of elements is one greater than the final valid index.
3. Reading an array and checking its positions
- Write down the array's values in order before tracing an access.
- Match the requested index to its position label.
- Check the bounds before deciding whether an access is valid.
4. Bounds in everyday array reasoning
- An array's bounds depend on how many elements it contains.
- Different kinds of values can be stored; indexes still identify positions.
- Do not assume that an index equal to the element count is valid.
Hand trace for the temperature example
| Action | Array or variable state | Result |
|---|---|---|
| Start | temperatures = [12, 15, 11, 18] | Four values; valid indexes 0 to 3 |
| Select index 2 | chosen = 11 | Index is within bounds |
| Print chosen | chosen = 11 | Expected output: 11 |
Worked example
Select one quiz score
The index labels identify positions; the cells show the stored scores.
Python 3
scores = [68, 74, 89]
selected = scores[1]
print(selected)- Label the positionsPython 3 uses zero-based indexes, so the first score is at index 0, the second at index 1, and the third at index 2.
- Check the requested indexThere are three scores, so the valid indexes are 0, 1, and 2. Index 1 is within those bounds and identifies the second score.
- Read the selected valueThe value in the second position is 74, so selecting index 1 gives 74.
Worked example
Recognize an index outside the bounds
The four existing positions end at index 3; index 4 has no corresponding element.
- Count the elementsThe list contains four names. With Python's zero-based indexes, their positions are labelled 0, 1, 2, and 3.
- Compare with the boundsIndex 4 is not one of the labels assigned to a name. The last valid index is 3, so index 4 is outside the bounds.
- State what can be selectedThe final name, Pine, is at index 3. There is no fifth list element at index 4.
Worked example
Trace a value chosen by an index
Index 2 labels the third value, 11.
Python 3
temperatures = [12, 15, 11, 18]
chosen = temperatures[2]
print(chosen)- Inspect the listThe input list has four values. Its Python indexes are 0, 1, 2, and 3, so index 2 is within the valid bounds.
- Trace the selectionStarting at index 0, the values are 12, 15, then 11 at index 2. The selected variable therefore holds 11.
- Determine the printed valueThe print statement displays the value held by the selected variable. Tracing the statements gives the expected output 11; this is a hand trace, not a claim that the code was executed.
Common mistakes and how to avoid them
Lesson summary
- A one-dimensional array is an ordered sequence of values under one name.
- An index identifies an element's position.
- Python 3 list indexes start at 0.
- For a zero-based array of elements, the valid indexes are 0 through .
- Check that an index is within the array's bounds before selecting its value.
Check your understanding
Question 1
- 9
- 4
- 7
- There is no valid index 0
Show answer and explanation
Question 2
- 3
- 4
- 5
- 6
Show answer and explanation
Question 3
- Yes, because there are two elements
- Yes, because indexes start at 1
- No, because the valid indexes are 0 and 1
- No, because a list cannot have index 0
Show answer and explanation
Key terms
- One-dimensional array
- An ordered sequence of values arranged as one list of positions.
- Index
- A position label used to identify an element in an array.
- Bounds
- The limits of the valid indexes for an array.
- Element
- One value stored at a position in an array.
Continue through ICS3U
View the complete ICS3U Ontario Grade 11 Computer Science curriculum and lessons
- A1.4 · Use Boolean, comparison, and arithmetic operators correctly
- A1.6 · Create and update one-dimensional arrays in a program
- 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
- A2.1 · Write a program with input, processing, and output
About this lesson and its review
Published by DoAssignment. This reviewed lesson follows Ontario Grade 11 Computer Science (ICS3U), expectation A1.5. 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.