从键盘输入一个列表,计算输出列表元素的均方差。请完善代码。 def mean(numlist): s=0.0 for Rum in numlist: s=s+num return s/len(numlist) def dev(numlist,mean):

admin2019-09-02  47

问题 从键盘输入一个列表,计算输出列表元素的均方差。请完善代码。
def mean(numlist):
s=0.0
for Rum in numlist:
s=s+num
return s/len(numlist)
def dev(numlist,mean):
sdev=0.0
for num in numlist:
sdev=sdev+(num—mean)**2
return(sdev/(len(numlist)一1))**0.5
#输入一个列表:
ls=eval(input(’’’’))
print(’’均方差为:{:.2f}’’.format())

选项

答案def mean(numlist): s=0.0 for num in numlist: s=s+num return s/len(numlist) def dev(numlist,mean): sdev=0.0 for num in numlist: sdev=sdev+(num—mean)**2 return(sdev/(len(numlist)一1))**0.5 ls=eval(input(’’’’)) print(’’均方差为:{:.2f}’’.format(dev(ls,mean(ls))))

解析
转载请注明原文地址:https://kaotiyun.com/show/Kj6p777K
0

相关试题推荐
最新回复(0)