Skip to main content
Module 4 · Manhattan Navigation

Lesson 4-2 · The Planner: A Path That Grows — Knowledge Checks

Name Date
  1. What does this print?

    stops = []
    stops.append((0, 1))
    stops.append((0, 2))
    stops.append((1, 2))
    print(len(stops), stops)
    1. A.3 [(1, 2), (0, 2), (0, 1)]
    2. B.3 [(0, 1), (0, 2), (1, 2)]
    3. C.6 [0, 1, 0, 2, 1, 2]
    4. D.1 [(1, 2)]

    Answer Why?

  2. A loop is meant to build a path, but the list ends up holding only the last position. What's wrong?

    1. A.append() is broken
    2. B.The append() line is outside the loop, so it runs only once
    3. C.The path should have been a tuple
    4. D.The loop ran too many times

    Answer Why?

  3. Why is the path for Leg 2, (2, 3) to (1, 0), empty?

    1. A.append() only works once per program
    2. B.Both while conditions are False from the start (2 is not < 1, 3 is not < 0), so neither loop runs
    3. C.The start and destination are the same
    4. D.The driver is still a stub

    Answer Why?

  4. Which is true?

    1. A.A tuple can grow with append(); a list cannot
    2. B.A list can grow and change; a tuple stays as it was made
    3. C.Lists and tuples are the same thing with different brackets
    4. D.A list can only hold numbers

    Answer Why?