通过本文主要向大家介绍了python时间序列分析,python 时间序列,python 时间序列预测,python 序列,python对象序列化等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
本文实例讲述了python计算一个序列的平均值的方法。分享给大家供大家参考。具体如下:
def average(seq, total=0.0):
num = 0
for item in seq:
total += item
num += 1
return total / num
</div>
如果序列是数组或者元祖可以简单使用下面的代码
def average(seq): return float(sum(seq)) / len(seq)</div>
希望本文所述对大家的Python程序设计有所帮助。
</div>
