Functions · Python exercise
Compute a power with a loop inside a reusable function.
Define a function named power that accepts a base and a non-negative exponent and returns base raised to that exponent. Do not use the ** operator or math.pow. Read two integers and print the result.
Example 1
Input
2 3
Output
8
Example 2
Input
5 0
Output
1
How testing works
Your code runs once per test case with that case's standard input. Output is compared after normalising trailing spaces and blank lines at the end. Use input() without a prompt when the exercise expects clean output.
Loading editor…
Press Run tests to execute your code against every input case. Python runs in a Web Worker in your browser.