Answer: Python Puzzler #2745

The answer is B. The program prints:

apple

This answer was checked by running the program for real.

Why?

Python counts list positions from 0, so position 3 is the fourth item.

Trace table

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

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

The code again

basket = ["plum", "pear", "mango", "apple", "grape", "banana"]
print(basket[3])

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