Skip to main content
Module 4 · Manhattan Navigation

Lesson 5 · Implementing the Manhattan Class — Knowledge Checks

Name Date
  1. What's the main advantage of the Manhattan class over the standalone function?

    1. A.It runs faster
    2. B.It stores the start position once, so you don't repeat it on every call
    3. C.It uses fewer while loops
    4. D.It doesn't need a destination

    Answer Why?

  2. After nav = Manhattan((2, 1)), what does nav.position hold?

    1. A.An empty tuple
    2. B.(2, 1)
    3. C.2
    4. D.Nothing until compute_path is called

    Answer Why?

  3. In the class version, where does the old start parameter's information come from now?

    1. A.It's passed to compute_path each time
    2. B.From self.position, stored back in __init__ when the object was created
    3. C.It defaults to (0, 0)
    4. D.From a global variable

    Answer Why?

  4. You create nav = Manhattan((0, 0)) and call nav.compute_path((2, 3)). Afterward, what is nav.position?

    1. A.(2, 3) — it moved to the destination
    2. B.(0, 0) — compute_path only reads self.position, it never changes it
    3. C.The full path list
    4. D.Undefined

    Answer Why?