Answer: Python Puzzler #1501

The answer is B. The program prints:

5
10
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 5, so the program prints the multiples of 5 up to 10.

Trace table

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

numbernumber % 5printed?
11
22
33
44
50yes
61
72
83
94
100yes

The code again

for number in range(1, 11):
    if number % 5 == 0:
        print(number)

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