这个为什么输出结果是1,跟示例的结果1.5输出不一致
# Enter a code
def average(*args):
lenth = len(args)
if lenth == 0 :
return 0;
else:
sum = 0
for item in args:
sum += item
avg = sum / lenth
return avg
print(average())
print(average(1,2))
# Enter a code
def average(*args):
lenth = len(args)
if lenth == 0 :
return 0;
else:
sum = 0
for item in args:
sum += item
avg = sum / lenth
return avg
print(average())
print(average(1,2))
2020-09-24
举报