Skip to main content
Module 1 · Learning to Drive

Lesson 10 · Python Functions — Knowledge ChecksAnswer key

Correct answers are marked and the explanation follows each question.

  1. Which keyword defines a function in Python?

    1. A.function
    2. B.def
    3. C.define
    4. D.func

    Python uses def, followed by the function name, parentheses, and a colon.

  2. Given def square(side_length):, what does calling square(45) make the robot do?

    1. A.Draw a square with 45 cm sides
    2. B.Draw a square with 90 cm sides
    3. C.Turn 45 degrees
    4. D.Cause an error — you must pass two numbers

    The argument 45 fills the side_length parameter, so each Straight drives 45 cm. One parameter, one argument.

  3. A variable created inside a function (like angle above) can be used…

    1. A.Anywhere in the program
    2. B.Only inside that function — it is local
    3. C.Only after the program ends
    4. D.Only in other functions

    Variables defined in a function are local to it. Code outside can't see angle — which keeps functions self-contained and safe.

  4. What's wrong with this? def multiply(x, y)

    1. A.multiply should be capitalized
    2. B.It is missing the colon: def multiply(x, y):
    3. C.x and y need quotes
    4. D.Nothing is wrong

    A def line, like a for line, must end with a colon before its indented body.