Answer: Python Puzzler #1314

The answer is C. The program prints:

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

Why?

Python works from the inside out. First triple(5) returns 15. Then that answer goes into triple again, which returns 45.

Trace table

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

stepvalue
triple(5)15
triple(15)45

The code again

def triple(number):
    return number * 3

print(triple(triple(5)))

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