Answer:
import statistics as st # importing statistics package to calculate mean as st.
grades = {"John": [87,90,86.8], "Mary": [78, 81.5, 88.6],"Susan":[45,67,76]}
for key,value in grades.items():#iterating over the dictionary
average_score=st.mean(value)#calculating the mean of every student
gr="" empty string to store the grades
if average_score>=90: # nested if else if and statements for the grades in gr
gr="A"
elif average_score>=80.0 and average_score<90.0:
gr="B"
elif average_score>=70.0 and average_score<80.0:
gr="C"
elif average_score>=60.0 and average_score<70.0:
gr="D"
else :
gr="F"
print(str(key)+" "+str(average_score)+" "+str(gr)) #printing grades of every student.
Output:-Mary 82.7 B
John 87.93333333333334 B
Susan 62.666666666666664 D
Step-by-step explanation:
1.In this program we are iterating over the dictionary grades.
2.Storing and calculating the mean of the scores of every student us statistics package.
3.Storing the grade in string gr and updating the gr according to the mean score
4.After that printing the grade of the student with their name and mean score.