sum=0
def average(*args): sum = 0.0 #想想sum = 0会是怎么样? if len(args)==0: return sum for i in args: sum=sum + i return sum/len(args) print average() print average(1, 2) print average(1, 2, 2, 3, 4)
def average(*args): sum = 0.0 #想想sum = 0会是怎么样? if len(args)==0: return sum for i in args: sum=sum + i return sum/len(args) print average() print average(1, 2) print average(1, 2, 2, 3, 4)
2019-06-29
举报