我们做入门算法题,,自己造轮子,,
1、求列表数值的总和
data = [3,10,23,5,6]
sum = 0
for i in range(len(data)):
sum = sum+data[i]
print(sum)
2、求列表数值的平均值
data = [3,10,23,5,6]
b = len(data)
sum = 0
for i in data:
sum = sum +i
print(sum/b)
我们做入门算法题,,自己造轮子,,
1、求列表数值的总和
data = [3,10,23,5,6]
sum = 0
for i in range(len(data)):
sum = sum+data[i]
print(sum)
2、求列表数值的平均值
data = [3,10,23,5,6]
b = len(data)
sum = 0
for i in data:
sum = sum +i
print(sum/b)