mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-12 09:39:49 +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:
|
||||
return half * half
|
||||
|
||||
|
||||
def power(a: int, b: int) -> float:
|
||||
"""
|
||||
: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.
|
||||
"""
|
||||
if b < 0:
|
||||
return 1 / actual_power(a, -b)
|
||||
return 1 / actual_power(a, -b)
|
||||
return actual_power(a, b)
|
||||
|
||||
|
||||
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