This tiny project lets you practice refactoring using two near-duplicate functions:
average_age(ages: list[float]) -> floataverage_score(scores: list[float]) -> float
You'll start from the function stubs (raise NotImplementedError), write the simplest implementation (Green), then refactor by extracting shared logic and eventually using a better built-in (sum).
poetry install
poetry run pytest -qTo run only the performance demo (prints timing info):
poetry run pytest -q -k perfThe perf test is for demonstration; it does not assert a strict speed ratio to avoid flakiness across machines.