Question 2
Back to Exercise
What is the output of the following Python program?
def countdown(n):
if n == 0:
print("Go!")
return
print(n)
countdown(n - 1)
countdown(3)
- A 1 2 3 Go!
- B Go! 1 2 3
- C 3 2 1 Go! Correct
- D 3 2 1 0 Go!
Correct Answer: Option C
Each call prints before recursing, so numbers appear in calling order, then the base case prints Go!.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!