Question 6
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
def power(base, exp=2):
return base ** exp
print(power(3, base=2))
- A It prints 8
- B TypeError: 3 already fills base by position, so base=2 gives base two values Correct
- C It prints 9
- D SyntaxError
Correct Answer: Option B
Python reports "got multiple values for argument 'base'". Call power(2, 3) or power(base=2, exp=3).
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!