Exercise 3 solution import timeit from collections import deque N = 100_000 def drain_list(): jobs = list(range(N)) while jobs: jobs.pop(0) def drain_deque(): jobs = deque(range(N)) while jobs: jobs.popleft() print("list ", timeit.timeit(drain_list, number=1)) print("deque", timeit.timeit(drain_deque, number=1)) Expectation: pop(0) moves every remaining item one place, so draining the list does work proportional to N squared overall, while popleft() is a constant amount of work per job. The deque should win by a wide margin, and the gap should grow if N grows. Exact seconds depend on your machine.