What does this print?
stops = []
stops.append((0, 1))
stops.append((0, 2))
stops.append((1, 2))
print(len(stops), stops)
- A.3 [(1, 2), (0, 2), (0, 1)]
- B.3 [(0, 1), (0, 2), (1, 2)]
- C.6 [0, 1, 0, 2, 1, 2]
- D.1 [(1, 2)]
Answer Why?
A loop is meant to build a path, but the list ends up holding only the last position. What's wrong?
- A.append() is broken
- B.The append() line is outside the loop, so it runs only once
- C.The path should have been a tuple
- D.The loop ran too many times
Answer Why?
Why is the path for Leg 2, (2, 3) to (1, 0), empty?
- A.append() only works once per program
- B.Both while conditions are False from the start (2 is not < 1, 3 is not < 0), so neither loop runs
- C.The start and destination are the same
- D.The driver is still a stub
Answer Why?
Which is true?
- A.A tuple can grow with append(); a list cannot
- B.A list can grow and change; a tuple stays as it was made
- C.Lists and tuples are the same thing with different brackets
- D.A list can only hold numbers
Answer Why?