python应用-一组数的最大值,最小值,平均数
def foo(n): c=[] for _ in range (n): var=randint(60,100) c.append(var) print(c) total=0 max = c[0] min=c[0] for i in range (1,n): total += c[i] if c[i]>=max: max=c[i] elif c[i]<=min: min=c[i] return max,min,total/9 if __name__ == '__main__': print(foo(8))
结果: [92, 88, 76, 76, 75, 92, 72, 84] (92, 72, 62.55555555555556)
千行代码,Bug何处藏。 纵使上线又怎样,朝令改,夕断肠。