Answer: Python Puzzler #2521

The answer is C. The program prints:

pear

This answer was checked by running the program for real.

Why?

Python counts list positions from 0, so position 4 is the fifth item.

Trace table

A trace table follows the program step by step. Here’s this one:

positionnegative positionitem
0-6apple
1-5grape
2-4carrot
3-3banana
4-2pear
5-1plum

The code again

basket = ["apple", "grape", "carrot", "banana", "pear", "plum"]
print(basket[4])

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