通过简单的python代码来计算平均数:
while True:
str = input("请输入数值,用空格隔开:")
list = str.split(" ") # list用空格分割
s = 0
for x in list:
s += float(x) # s为输入数字的总和
avg = s/len(list)
print('平均数 = ',avg)
通过简单的python代码来计算平均数:
while True:
str = input("请输入数值,用空格隔开:")
list = str.split(" ") # list用空格分割
s = 0
for x in list:
s += float(x) # s为输入数字的总和
avg = s/len(list)
print('平均数 = ',avg)