Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

In this topic students learn to store data that has rows and columns in a 2D array, and to work through one with nested loops.

Learning objectives and goals

Be able to read, comprehend, trace, adapt and create Python code that:

Slide deck

This chapter has no slide deck. It was written for Dodona from new material by the course author, after the rest of the course had been converted.

Teacher notes

This chapter builds directly on Lists. The exam specification calls the structure a 2D array, and the activities use that term throughout. Python has no separate array type for it: it is a list whose items are lists. The theory page says so once and points back to the Lists chapter, because everything students already know about a list still works on the outer list (which holds rows) and on each row.

The most useful thing to establish early is the reading order of array[row][column]: Python picks the row first, and then an item from that row. Students who read scores[1][3] as “row 1, then item 3 of that row” rarely swap the indices; students who read it as “a coordinate” often do, especially if they are used to (x, y) from maths, where across comes first.

Nested loops are the second idea. Students first met them in the String manipulation chapter, over a list of words; here they get their natural home. Tracing one on the board, with a column for each counter, is worth the time: the moment students see that the inner counter runs all the way through before the outer one moves on, the rest of the chapter follows.

Key points

Errors and misconceptions