Answer: Python Puzzler #47

The answer is C. The program prints:

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

Why?

len counts every character, including spaces and punctuation. ‘Pixel cat’ has 9.

Trace table

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

countcharacter
1P
2i
3x
4e
5l
6(space)
7c
8a
9t

The code again

word = "Pixel cat"
print(len(word))

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