Answer: Python Puzzler #104

The answer is D. The program prints:

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

Why?

len counts every character, including spaces and punctuation. ‘hello world’ has 11.

Trace table

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

countcharacter
1h
2e
3l
4l
5o
6(space)
7w
8o
9r
10l
11d

The code again

word = "hello world"
print(len(word))

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