【发布时间】:2019-10-12 17:38:39
【问题描述】:
我有一个测试平均值计算器,用户可以输入他们想要多少测试分数(以 1-100 为单位)。我只需要跟踪用户输入的测试分数。我将如何实现它?
#Welcome Message
print("Welcome to the Test Average Calculator!")
print("Say 'STOP' when you are done with Data Entry")
#Variables
total = 0
total_quiz = 0
inpt = input("Enter score: ")
#User Input
while inpt.upper() != "STOP":
if int(inpt) <= 100 and int(inpt) > 0:
total += int(inpt)
total_quiz += 1
else:
print("Invalid Score")
inpt = input("Enter Score or Stop?: ")
#Display Average
print('The Average score is: ',
format(average, '.2f'))
【问题讨论】:
标签: python-3.x average