Answer: Python Puzzler #1450

The answer is C. The program prints:

3
6
9
12
What the program prints
Checked by running the program for real.

Why?

% gives the remainder after dividing. A remainder of 0 means the number divides exactly by 3, so the program prints the multiples of 3 up to 12.

Trace table

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

numbernumber % 3printed?
11
22
30yes
41
52
60yes
71
82
90yes
101
112
120yes

The code again

for number in range(1, 13):
    if number % 3 == 0:
        print(number)

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