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)