Answer: Python Puzzler #1508

The answer is B. The program prints:

4
8
12
16
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 4, so the program prints the multiples of 4 up to 16.

Trace table

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

numbernumber % 4printed?
11
22
33
40yes
51
62
73
80yes
91
102
113
120yes
131
142
153
160yes

The code again

for number in range(1, 17):
    if number % 4 == 0:
        print(number)

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