Loading...
Loading...
Loading...
A pricing tool squares a value by default, but sometimes needs another exponent. Write power(base, exp=2). The first input line says how many numbers follow: with 1, call power(base); with 2, call power(base, exp). Print the result.
Example 1
Input
1 5
Output
25
Only a base: the default exponent 2 is used.
Example 2
Input
2 2 10
Output
1024
Base 2, exponent 10.
Try the problem first. Open one hint at a time.
The first line tells you whether a second number follows.
Pass the exponent only when it is present, so the default applies otherwise.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor