import math
lst=[]str=input("输入:")
lst1 = str.split(" ")
i = 0
t=len(lst1)
while i <= t+1:
if len(lst1)==0:
break
else:
lst.append(float(lst1.pop()))#将lst1的数据转换为整型并赋值给lst
i += 1
def sum1(list):
"对列表的数值求和"
s = 0
for x in list:
s += x
return s
def average(list):
"对列表数据求平均值"
avg = 0
avg = sum1(lst)/float(len(lst)*1.0) #调用sum函数求和
return avg
def var(list,avg):
"""利用list 和均值计算方差"""
var1=0
for i in list:
var1+=float((i-avg)**2*1.0)
var2=(math.sqrt(var1/(len(lst)-1)*1.0))
return var2
print("sum= %f"%sum1(lst))
print("avg = %f"%average(lst))
print("s = %f"%var(lst,average(list)))