In: Computer Science
You're a statistics professor and the deadline for submitting your students' grades is tonight at midnight. Each student's grade is determined by their mean score across all of the tests they took this semester.
(The mean is the average of the numbers. It is easy to calculate: add up all the numbers, then divide by how many numbers there are)
You've decided to automate grade calculation by writing a Python program that takes a list of test scores and prints a one character string representing the student's grade calculated as follows:
90% <= mean score <= 100%: "A",
80% <= mean score < 90%: "B",
70% <= mean score < 80%: "C",
60% <= mean score < 70%: "D",
mean score < 60%: "F"
For example, if list1 = [92, 94, 99], it would print "A" since the mean score is 95, and if list1 = [50, 60, 70, 80, 90], it would return "C" since the mean score is 70.
def printGrade(scores):
avg=0
#iterating the list
#finding sum
for x in scores:
avg+=x
#finding the average
avg=avg/len(scores)
#checking average to print grade
if(avg>=90):
print("A")
elif(avg>=80):
print("B")
elif(avg>=70):
print("C")
elif(avg>=60):
print("D")
else:
print("F")
printGrade([92,94,99])
printGrade([50,60,70,80,90])
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me