题目描述
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
保证base和exponent不同时为0
class Solution: def Power(self, base, exponent): # write code here if base == 0: return False if base == 1 or exponent==0: return 1 res = 1 for i in range(abs(exponent)): res*=base if exponent < 0: res = 1/res return res
2019-12-03 09:48:41