return sum(args)/len(args)
def average(*args):
if len(args)==0:
return 0.0
return sum(args)/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
结果是0.0
1
2
有人能解释一下吗,有些不懂
def average(*args):
if len(args)==0:
return 0.0
return sum(args)/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
结果是0.0
1
2
有人能解释一下吗,有些不懂
2017-08-16
举报