Commute times with the same mean but different medians

Predict the output · Medium · §8.1 Differences the average hides

These are commute times (minutes) for five trips each by subway and by bus. For each mode of transport, the code prints the mean, the median, and the range (the largest value minus the smallest) on one line. Predict the two lines of output without running the code.

Code

subway = [35, 30, 38, 32, 35]
bus = [20, 80, 15, 30, 25]

for name, minutes in [("subway", subway), ("bus", bus)]:
    mean = sum(minutes) / len(minutes)
    median = sorted(minutes)[len(minutes) // 2]
    print(name, mean, median, max(minutes) - min(minutes))

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.