Problem
Hints
Solutions
Submissions
Pow(x, n)
Implement pow(x, n), which calculates x raised to the power n.
Constraints
-100.0 < x < 100.0
-2^31 <= n <= 2^31 - 1
n is an integer.
Either x is not zero or n > 0.
-10^4 <= x^n <= 10^4
View editorial solution
Back
Python 3.8
Saving… · 2 lines
9
1
2
›
⌄
class
Solution
:
def
power
(
self
,
x
:
float
,
n
:
int
)
->
float
:
Console
Run
Submit
Click Run to execute sample tests.