Arrays: 1D and 2D
About this lesson: Arrays: 1D and 2D
In short
An array stores many values of the same type under one name. Each item has an index.

What you'll explore
- Why arrays?: One name instead of many
- An array stores many values of the same type under one name. Each item has an index.
- Indexing: Pick one item
- Use an index to read one item. Move the index.
- Looping through an array: Visit every item
- A FOR loop with the index as its counter visits every element. Step through.
- 2D arrays: Rows and columns
- A 2D array is a table. scores[row, col] picks one cell. Move the sliders, then show row totals with nested loops.
- Check yourself: 2D index
- scores[2, 0] in the table: row 2 is Chidi, column 0 is T1.
Also in this lesson
- Step by step
- Watch out for these
- More than the lesson
- Stretch your brain
- Try it yourself
Words to know
- Array
- A data structure holding many values of one type under one name.
- Element
- One item in an array.
- Index
- The position number of an element.
- 2D array
- An array with rows and columns.
- Nested loop
- A loop inside another loop.
Sources
- Python documentation: Lists
- Raspberry Pi Foundation, Isaac Computer Science: arrays
- BBC Bitesize, GCSE Computer Science: arrays
- Khan Academy: arrays in programming
← Strings and nested selection · Linear search and bubble sort →