标签:self style ase lse coding sel als ret else
1 # -*- coding:utf-8 -*- 2 class Solution: 3 def Power(self, base, exponent): 4 if exponent == 0: 5 return 1 6 if exponent == 1: 7 return base 8 op = False 9 if exponent < 0: 10 op = True 11 exponent = -exponent 12 result = 1 13 if exponent % 2 == 0: 14 result = self.Power(base * base,exponent // 2) 15 else: 16 result = self.Power(base * base,exponent // 2) * base 17 if op: 18 result = 1 / result 19 return result 20 # write code here
标签:self style ase lse coding sel als ret else
原文地址:https://www.cnblogs.com/asenyang/p/11013104.html