Answer: Python Puzzler #1721

The answer is A. The program prints:

I
What the program prints
Checked by running the program for real.

Why?

word[1:2] is a slice: it starts at position 1 and stops before position 2. Positions count from 0.

Trace table

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

positionletter
0P
1I
2X
3E
4L

The code again

word = "PIXEL"
print(word[1:2])

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