SigmaAnalytics & Tech
A9PythonBeginnerAbout 120 min to complete

Dictionaries

Fluency with Python's most powerful container — and the structure that every API, config file, and JSON document on earth is made of.

Notebook

About 120 minutes to complete

Enrol to read the notebook and download it to run.

What this module covers

Fluency with Python's most powerful container — and the structure that every API, config file, and JSON document on earth is made of.

By the end of it

  • Create dictionaries five ways, including from zip() and with comprehensions
  • Access values safely with .get() and .setdefault(), avoiding KeyError
  • Apply every core method and iterate with .items(), .keys(), .values()
  • Explain the hashability requirement for keys, connecting it back to Notebook 08
  • Write dictionary comprehensions to transform, filter, and invert mappings
  • Navigate nested dictionaries — the structure of every JSON document
  • Use defaultdict and Counter to make grouping and counting trivial
  • Merge dictionaries with |, **, and .update(), and predict which value wins