Question 9
Back to Exercise
What is the output of the following Python program?
i = 5
def f(arg=i):
return arg
i = 6
print(f(), f(7))
- A 6 7
- B 5 5
- C 5 7 Correct
- D 6 6
Correct Answer: Option C
The default is evaluated when def runs, while i is still 5. Changing i later does not affect it.
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!