round() 对int、float类型数据进行四舍五入,返回一个浮点数,可以在第二个参数控制精度(但是有时精度会失效。help(round)中提到:Precision may be negative)
pow()函数:
pow ( number $base , number $exp )
-
The base to use
-
指数
base
exp
return:用于返回某个值。在调用函数时经常使用
例如:
def powersum(power,*args):
total=0
print args
for i in args:
#print total
total+=pow(i,power)
print total,'\n' #如果把该句放在return下面,那么就先返回return,该句就不执行了。
return total
print powersum(2,3,4)
本文介绍Python中的round()函数用于对整数和浮点数进行四舍五入,以及pow()函数用于计算数值的幂次方。通过实例演示如何使用这些函数,并解释函数的使用技巧及注意事项。

2916

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



