practicepython.in
python exercises
171 exercises

Making code trustworthy

The work that happens at the edges of a program: checking what arrived, converting it, and saying clearly what was wrong with it. Most bugs that reach production got in because something was accepted that should have been refused — and most of the rest because the refusal said nothing useful.

8 exercisesdifficulty 2–4~167 min in total
Comparing floats without lying float equality, relative versus absolute tolerance ~15 min An error message somebody can act on what a message must contain, !r for ambiguous values ~18 min Report every missing field at once collecting errors, present but falsy ~15 min Everything arrives as a string converting at the boundary, bool('False') is True ~24 min One shape in, one shape out accepting more than one shape, one cleaning path ~20 min Rules as functions, errors as data rules you can pass around, collecting every failure ~24 min Code that asks for the time instead of taking it injecting the clock, reading a value once ~25 min A block of code that has to leave something alone context managers, post-conditions ~26 min