Answer: Python Puzzler #1360

The answer is B. The program prints:

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

Why?

Python works from the inside out. First double(6) returns 12. Then that answer goes into double again, which returns 24.

Trace table

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

stepvalue
double(6)12
double(12)24

The code again

def double(number):
    return number * 2

print(double(double(6)))

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