我的最后一个问题是将平均值浮动到小数点后 1 位,例如。平均 34.1
这是我当前的代码:
total = 0.0
count = 0
data = float(input("Enter a number or enter to quit: "))
while data != "":
count += 1
number = float(data)
total += number
data = float(input("Enter a number or enter to quit: "))
try:
data = int(data)
except ValueError:
pass
average = round(total) / count
if data == 999:
break
elif data >= 100:
print("error in value")
elif data <= 0:
print("error in value")
print("These", count, "scores average as: ", round(average, 1))