missing = 0
highscore = 0
inclass = 0
takenexam = 0
count = 0
total = 0
minGrade = 100 #assuming 100 is the highest grade possible.
maxGrade = 0
score = int(input("Enter a score (-1 to quit): "))
while score > -1 :
if score >= 80 :
highscore = highscore + 1
if score == 0 :
missing = missing + 1
if 0 <= score <= 100 :
inclass = inclass + 1
if 0 < score <= 100 :
takenexam = takenexam + 1
# Determine if the score is the min or max score.
if score < minGrade :
minGrade = score
if score > maxGrade :
maxGrade = score
# Add the grade to the running total
total = total + score
count = count + 1
# Read the next grade.
score = int(input("Enter a score (-1 to quit): "))
# Print the results.
if count > 0 :
average = total / count
print("number of students in the class: ", inclass)
print("number of students who missed the exam: ", missing)
print("number of students who took the exam: ", takenexam)
print("number of students who scored high: ", highscore)
print("The average of all students in the class %.2f" % average)
这就是我目前的编码方式,我现在很好奇如何帮助它满足一个句子控制的循环,以及如何添加所有参加考试的学生的平均值?