Python计算平均数

代码如下:

第一种方法
scores =  [91, 95, 97, 99, 92, 93, 96, 98]
avg = sum(scores) / len(scores)
print(avg)
结果:
95.125

第二种方法
import numpy
print(numpy.mean(scores))
结果:
95.125

  

原文地址:https://www.cnblogs.com/lucktomato/p/15330610.html