Skip to main content
Module 4 · Manhattan Navigation

Lesson 4-1 · The Main Program — Knowledge ChecksAnswer key

Correct answers are marked and the explanation follows each question.

  1. The robot is 3 across and 1 up from the corner nearest you. Which line stores that?

    1. A.robot_position = (1, 3)
    2. B.robot_position = (3, 1)✓
    3. C.robot_position = 3, 1, 0
    4. D.robot_position = [3] + [1]

    x comes first: 3 across, then y: 1 up. Both numbers count from 0, so the corner itself is (0, 0).

  2. How many lines does this print, and what is the last one?

    STOPS = [(1, 1), (0, 2), (3, 3)]
    for stop in STOPS:
        print("Go to", stop)
    1. A.One line: Go to [(1, 1), (0, 2), (3, 3)]
    2. B.Three lines; the last is Go to (3, 3)✓
    3. C.Six lines, one for each number
    4. D.Three lines; the last is Go to 3

    The loop runs once per item, and each item is a whole tuple. Three items, three lines, in list order.

  3. A student calls drive_path(path, robot_position, robot_heading) on its own line, with nothing on the left, then plans the next leg. What goes wrong?

    1. A.Nothing: drive_path() updates robot_position for them
    2. B.robot_position and robot_heading never changed, so the next leg is planned from the old spot✓
    3. C.Python raises an error about an unused return value
    4. D.The robot drives the path twice

    current_position inside drive_path() is the function's own variable. The main program only learns the new pose by assigning from the return: robot_position, robot_heading = drive_path(...).