Add a function to determine the letter grade A B C D or F of
Solution
dict = {90:\"A\",80:\"B\",72:\"C\",62:\"D\"}
def get_max(list):
return max(list)
def grade(score):
for i in dict:
if(score>=i):
return dict[i]
file = open(\"scores.txt\",\"r\")
data = file.read().split(\"\ \")
for line in data:
stud = line.split(\" \")
scores = map(int,stud[1:])
print \"Student Name:\"+stud[0]
print \"Exam #1:\",scores[0],grade(scores[0])
print \"Exam #2:\",scores[1],grade(scores[1])
print \"Exam #3:\",scores[2],grade(scores[2])
print \"Highest score:\",get_max(scores)
\"\"\"
sample output
Student Name:Amy
Exam #1: 90 B
Exam #2: 98 B
Exam #3: 85 B
Highest score: 98
Student Name:Melanie
Exam #1: 80 B
Exam #2: 89 B
Exam #3: 90 B
Highest score: 90
Student Name:Bob
Exam #1: 62 D
Exam #2: 55 None
Exam #3: 76 C
Highest score: 76
Student Name:Timothy
Exam #1: 80 B
Exam #2: 79 C
Exam #3: 72 C
Highest score: 80
\"\"\"

