Module 1 · Learning to Drive
Lesson 1-12 · Python Final Project — Knowledge ChecksAnswer key
You're about to build a 60-block-worth Python program. What's the smartest way to start?
Build and test in small pieces (unit testing), then integrate. It's far easier to find a bug in one small function than in a giant program.
What is the difference between these two ways of describing a function?
# Return the exterior angle def calculate_angle(sides): """Return the exterior angle."""Both are for humans, but only the docstring survives: Python attaches it to the function, so help() and your editor can show it. A comment is thrown away once the file is read.
Your program runs but the robot behaves differently each time on the same code. Most likely cause?
If the code is unchanged and the result varies, it's usually physics — grippier surface, fresher battery, or wheel slip — not a code bug.