Module 1 · Learning to Drive
Lesson 10 · Python Functions — Knowledge ChecksAnswer key
Which keyword defines a function in Python?
Python uses def, followed by the function name, parentheses, and a colon.
Given def square(side_length):, what does calling square(45) make the robot do?
The argument 45 fills the side_length parameter, so each Straight drives 45 cm. One parameter, one argument.
A variable created inside a function (like angle above) can be used…
Variables defined in a function are local to it. Code outside can't see angle — which keeps functions self-contained and safe.
What's wrong with this? def multiply(x, y)
A def line, like a for line, must end with a colon before its indented body.