return s / len(numbers) #6除以3等于平均值2 # 计算方差,需要算出平均值 def dev(numbers,mean): #两参数用户输入列表和平均值 sdev = 0.0 #例:numbers=1,2,3,4 共4个数字 上一步算出平均值2.5 for num in numbers: #(1-2.5)**2==2.25 sdev=2.25 sdev = sdev + (num - mean)**2 #...
importstatistics data=[1,2,3,4,5]count=len(data)total=sum(data)average=total/count variance=statistics.variance(data)median=statistics.median(data)print("数据集:",data)print("总数个数:",count)print("总和:",total)print("平均值:",average)print("方差:",variance)print("中位数:",median) 1...