>>>defpowersum(power,*args):...'''Returnthesumofeachargumentraisedtospecifiedpower.'''...total=0...foriinargs:...total+=pow(i,power)...returntotal...>>>powersum(2,3,4)25请...
>>>def powersum(power, *args):
... '''Return the sum of each argument raised to specified power.'''
... total = 0
... for i in args:
... total += pow(i, power)
... return total
...
>>> powersum(2, 3, 4)
25
请问其中25这个数字怎么得来的我初学,讲解的详细点。
展开
本文介绍了一个Python函数,该函数能够计算输入参数的幂次方后求和。通过实例演示了如何使用此函数,例如计算3和4的平方和为25的过程。
2913

被折叠的 条评论
为什么被折叠?



