mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-12 17:49:50 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
bcd0b508c3
commit
9e6c74cd9f
@ -26,6 +26,7 @@ def actual_power(a: int, b: int):
|
|||||||
else:
|
else:
|
||||||
return half * half
|
return half * half
|
||||||
|
|
||||||
|
|
||||||
def power(a: int, b: int) -> float:
|
def power(a: int, b: int) -> float:
|
||||||
"""
|
"""
|
||||||
:param a: The base (integer).
|
:param a: The base (integer).
|
||||||
@ -33,8 +34,9 @@ def power(a: int, b: int) -> float:
|
|||||||
:return: The result of a^b, as a float for negative exponents.
|
:return: The result of a^b, as a float for negative exponents.
|
||||||
"""
|
"""
|
||||||
if b < 0:
|
if b < 0:
|
||||||
return 1 / actual_power(a, -b)
|
return 1 / actual_power(a, -b)
|
||||||
return actual_power(a, b)
|
return actual_power(a, b)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(power(-2, -3)) #output -0.125
|
print(power(-2, -3)) # output -0.125
|
||||||
|
Loading…
x
Reference in New Issue
Block a user