Answer: Python Puzzler #1703

The answer is B. The program prints:

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

Why?

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

Trace table

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

positionletter
0C
1O
2M
3P
4U
5T
6E
7R

The code again

word = "COMPUTER"
print(word[4:7])

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