def mypow(base, exp):
power = 1
while True:
if exp & 1:
power *= base
exp >>= 1
if not exp:
break
base *= base
return power
print(mypow(2, 3)) # 8
print(mypow(3, 3)) # 27
print(mypow(3, 2)) # 9
print(mypow(2, 2)) # 4
print(mypow(5.0, 2)) # 25
print(mypow(-2, 4)) # 16
'''
run:
8
27
9
4
25.0
16
'''