我需要一些帮助。我是一个完全不懂编程的人,我试图想出一个函数来打印Zscore的最大数字、最小数字和列表的平均值。我只能把数字打印在一个方程中,但不能解开。我必须使用原始的python来计算分数。
population = [14, 28, 96, 97, 21, 29, 29, 4, 58,
42, 25, 97, 49, 33, 75, 53, 14, 53,
45, 87, 75, 66, 62, 55, 57, 44, 44,
94, 19, 96, 12, 59, 86, 88, 61, 68,
37, 64, 19, 46, 68, 98, 19, 54, 65,
30, 1, 82, 76, 3]
def mean(data_set):
return sum(data_set)/len(data_set)
def stdev(data_set):
variance = sum([(integer - mean(population)) ** 2 for integer in data_set])/len(data_set)
return variance ** .5
def least(data_set):
return min(data_set)
def greatest(data_set):
return max(data_set)
def z_score(population):
zscore1 = f'{greatest(population)} - {mean(population)} / {stdev(population)}'
zscore2 = f'{least(population)} - {mean(population)} / {stdev(population)}'
zscore3 = f'{mean(population)} - {mean(population)} / {stdev(population)}'
return zscore1, zscore2, zscore3
print(z_score(population))