Answer: Python Puzzler #3991

The answer is C. The program prints:

1
Zap
3
Zap
5
Zap
7
Zap

This answer was checked by running the program for real.

Why?

Every number that divides exactly by 2 (remainder 0) is replaced by ‘Zap’. All the others are printed as they are.

Trace table

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

numbernumber % 2printed
111
20Zap
313
40Zap
515
60Zap
717
80Zap

The code again

for number in range(1, 9):
    if number % 2 == 0:
        print("Zap")
    else:
        print(number)

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