Skip to main content
Module 4 · Manhattan Navigation

Lesson 4-4 · The Driver — Knowledge ChecksAnswer key

Correct answers are marked and the explanation follows each question.

  1. What does this print?

    path = [(1, 0), (2, 0), (2, 1)]
    last = path[2]
    print(last[1])
    1. A.(2, 0)
    2. B.1✓
    3. C.2
    4. D.An IndexError

    Indexes count from 0, so path[2] is the third item, (2, 1). Then last[1] is its second part, y: 1.

  2. The robot moves from (2, 3) to (3, 3). Which direction is that, and what heading?

    1. A.North, heading 0
    2. B.South, heading 2
    3. C.East, heading 1✓
    4. D.West, heading 3

    x went 2 to 3 (x +1) and y stayed 3. Increasing x is moving right, East: heading 1.

  3. Going from (1, 3) to (1, 2), what does get_desired_heading() return?

    1. A.0 (North)
    2. B.1 (East)
    3. C.2 (South)✓
    4. D.3 (West)

    x is unchanged; y went 3 to 2 (y −1). Decreasing y is moving toward you: South, heading 2.