liveBook · Manning

Array

As explained in Learn AI-Assisted Python Programming, Second Edition

A two-dimensional list is a list whose elements represent rows or nested collections, forming a grid-like structure.

An array is an indexed collection of values. In Python, two-dimensional data can be represented as a list whose elements are lists: each inner list is a row, and each position within it is a column. section 5.1.2

Olympic medal data

A medal table can become [[2, 0, 2], [1, 2, 0], [1, 1, 0], [0, 1, 0], [1, 0, 0]]. Access medals[0] to retrieve a row or medals[0][0] to retrieve a particular value. Nested for loops process every row and column. section 5.1.2

>>> medals = [[2, 0, 2],
...           [1, 2, 0],
...           [1, 1, 0],
...           [0, 1, 0],
...           [1, 0, 0]]

Browse the compact Python representation of the Olympic medal table. section 5.1.2

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains list-of-lists storage, row and column indexing, and nested iteration without discussing array-library internals.
Examples
Uses a 2018 Winter Olympics medal table represented as rows of gold, silver, and bronze counts.
What you can do after
Build it from scratch with Python lists, retrieve individual values, and process every row and column using nested loops.
How it connects
Connects arrays with two-dimensional data, lists, indexing, rows and columns, and nested loops.

Also explained in

Compare how 40 books explain array →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.