Answer: Python Puzzler #20

The answer is B. The program prints:

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

Why?

len counts every character, including spaces and punctuation. ‘Beep’ has 4.

Trace table

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

countcharacter
1B
2e
3e
4p

The code again

word = "Beep"
print(len(word))

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