网络编程
位置:首页>> 网络编程>> Python编程>> python实现数组求和与平均值

python实现数组求和与平均值

作者:裸禄棍交比火牛  发布时间:2021-09-27 07:15:49 

标签:python,数组,求和,平均值

数组求和与平均值

ls=[4,9,19,8,391,39,9,283,45]
sum(ls)
average=sum(ls)/len(ls)
print('累加值',sum(ls),'平均值',average)

求数组元素的平均值

Python 环境:Python 2.7.12 x64

IDE:Wing IDE Professional  5.1.12-1

题目:求数组元素的平均值

#求数组元素的平均值

a=[1,4,8,10,12]
b=len(a)
sum=0
print "数组长度为:",b
for i in a:
   sum=sum+i
print "均值为:",sum/b
   

python实现数组求和与平均值

来源:https://blog.csdn.net/weixin_44220805/article/details/105306066

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com