Predict Function with Default Arg
Predict Output Easy
Question
What does this code print?
Code
def power(base, exp=2):
return base ** exp
print(power(3))
print(power(2, 3))
Hint
The second call overrides the default.
Explanation
power(3) uses the default exp=2, so 32 = 9. power(2, 3) uses exp=3, so 23 = 8. Output: 9 then 8.
Related Resources
Related Lessons
- Python Functions
Default arguments.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.