Define a function called power that takes a base and an optional exponent parameter (default 2)
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Define a function called power that takes a base and an optional exponent parameter (default 2). It should print "<base> to the power of <exponent> is <result>". Call it three times: power(5), power(3, 3), and power(2, 10).
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.