Lite / Building Machines That Respond / Week 7
Week 7: Functions
This week you will
- Package a calculation as a function with parameters, a return value and a docstring stating units.
- Write assert-based tests with independently worked expected values and float tolerances.
- Decompose a data-processing program into small, separately tested functions.
Lessons
- Package a calculation as a function · about 35 min
A robot converts wheel rpm to speed in six places in its code. One of them has a bug. How do you fix all six at once? - Promises and proof: tests with assert · about 35 min
Three versions of a °C-to-°F function all run without errors. Only one is right. How can three lines of tests tell them apart instantly? - Decompose a program into functions · about 40 min
Raw ADC counts in, a temperature report out. Should that be one long block of code, or three small functions?