Answer: Python Puzzler #3522

The answer is B. The program prints:

EEPBOO

This answer was checked by running the program for real.

Why?

word[1:7] is a slice: it starts at position 1 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
0B
1E
2E
3P
4B
5O
6O
7P

The code again

word = "BEEPBOOP"
print(word[1:7])

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