Going further exercises#

← Back to Going further

Three isolated exercises, one per note. Each stands on its own; do them in order if you're going through the notes in order, or use one on its own as a smaller rep of a single idea before or after the main project in ../project/. None of them are required, the same way the project step is the actual test of this module, not these.

  1. 01_define_a_class.py, matching notes/01-classes.md: define a plain class with __init__ and one method.
  2. 02_add_type_hints.py, matching notes/02-type-hints.md: add type hints to three working functions without changing their behavior.
  3. 03_dataclass_refactor.py, matching notes/03-dataclasses.md: turn a plain class into a @dataclass, fixing a mutable-default bug along the way.

Each file has its task in a docstring at the top and a # your code here marker. Run one with python exercises/01_define_a_class.py (adjust the filename) from the weeks/09-going-further folder.

There's no solutions/ folder for these, the same as the rest of this module: each task is small enough, and each note it matches is short enough, that writing your own solution and rereading the note if something doesn't click is the actual exercise.