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)

posted @ 2018-03-11 22:05  圆柱模板  阅读(992)  评论(0编辑  收藏  举报