Write a program to calculate the average of
all scores entered between 0 and 100. Use a
sentinel-controlled loop variable to terminate the
loop. After values are entered and the average
calculated, test the average to determine whether
an A, B, C, D, or F should be recorded.
sumScore=0
totalScores=0
score=0
while score != -1:
score = int(input( "Enter a score [0-100], (enter -1 to STOP): " ))
if score>=0 and score<=100:
sumScore+=score
totalScores+=1
average=sumScore/totalScores
if average>=90 and average<=100:
print("A")
elif average>=80 and average<90:
print("B")
elif average>=70 and average<80:
print("C")
elif average>=60 and average<70:
print("D")
else:
print("F")
Comments
Leave a comment