Part 1 · Section 08

Tuples as Data Records

A tuple is usually introduced as an “immutable list”, but that misses its most useful role. Because a tuple can never be resized or reordered, the position of each element can carry meaning, the way the position of each character gives a word its meaning. That makes tuples natural data records: a point is (x, y), a city is (name, country, population). Named tuples take the idea one step further by giving every position a name, so you get readable, immutable records with almost no code and no overhead.

In this section you’ll learn:

Lectures

  1. 01Tuples as Data Structures✓
  2. 02Named Tuples✓
  3. 03Named Tuples - Modifying, Extending✓
  4. 04Named Tuples - Docstrings, Default Values✓
  5. 05Named Tuples - Application - Alternative to Dictionaries✓
  6. 06Named Tuples - Application - Returning Multiple Values✓

Practice: quiz & exercises

11 quiz questions · 3 coding exercises

Go to practice →