M12) Line execution order in nested calls

The main function in Listing 1 passes the result of double(3) to add_one. The comments A to E mark lines in the function bodies. Consider only those marked lines when tracing the program.

Listing 1: Nested calls with five marked lines to trace.
def add_one(number: int) -> int:
    result = number + 1  # A
    return result         # B


def double(number: int) -> int:
    result = number * 2  # C
    return result         # D


def main() -> None:
    value = add_one(double(3))
    print(value)  # E


main()

In what order does Python execute the marked lines, and what does the program print?

  1. C, D, A, B, E; prints 7
  2. A, B, C, D, E; prints 8
  3. C, A, D, B, E; prints 7
  4. E, C, D, A, B; prints 7