Answer: Python Puzzler #3054

The answer is D. The program prints:

[2, 10, 16, 29, 40]

This answer was checked by running the program for real.

Why?

sort() puts the list in order, smallest first. It changes the list itself.

The code again

scores = [10, 40, 16, 2, 29]
scores.sort()
print(scores)

Try it: change one number in the program and predict the new output before you run it.