liveBook · Manning

Data structure

As explained in Python Workout: 50 ten-minute exercises

A data structure is an organized representation for storing and manipulating data in a program.

A data structure organizes data so a program can transform and compare it meaningfully. Reading a country-and-population file as a string makes comparisons awkward; reading it into a dict makes comparing France and Thailand straightforward. section 5.10

Useful file-to-structure exercises include:

  • Count each vowel in a text file with a dict. section 5.5
  • Group users by login shell, storing each shell’s users in a list. section 5.10
  • Represent each username with a nested dict containing user ID, home directory, and shell. section 5.10

The same translation applies to standard formats such as CSV and JSON: move between file text and built-in Python data types, then operate on the resulting structure. section 5.36

How Python Workout: 50 ten-minute exercises covers it

How deep it goes
Works through dicts, lists, and nested dicts, but does not develop data-structure internals or implementation trade-offs.
Examples
Uses country populations, vowel counts, login-shell groups, numeric input factors, and nested user records.
What you can do after
Builds Python dictionaries and related structures from file contents, then performs meaningful queries and aggregations.
How it connects
Connects data structures with files, CSV, JSON, dictionaries, lists, and text-file iteration.

Also explained in

Compare how 10 books explain data structure →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Workout: 50 ten-minute exercises. The section links point to the parts of the book it draws on.