Python power函数

power函数

from math import pow

def power(x, y):
    if y == 0:
        return 1
    tot = 1
    for i in range(y):
        tot *= x
    return tot
    
if __name__ == '__main__':
    for x in range(5):
        for y in range(5):
            print('Pow(x, y):\t', x, y, int(pow(x, y)))
            print('Power(x, y):\t', x, y, power(x, y))

 

posted @ 2019-06-30 09:16  no樂on  阅读(3034)  评论(0编辑  收藏  举报