LearnFrenzy
Sign in Take a free test

Functions · Find the Error · Question 6

Error: an argument given twice Answer, explanation & discussion

  • Find the error
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

The program below stops with an error. Which statement correctly describes the problem?

main.py
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links