Write a program that reads marks in three subjects and assign grades on the basis of percentage of marks.
%Marks Grade
>75 'A'
60-75 'B'
50-60 'C'
40-50 'D'
<40 'FAIL'
(Irrelevant answers will be report)
Answers
Answered by
7
def grader(marks):
grade_obj = {}
for idx, item in enumerate(marks, start = 1):
if item > 75:
grade_obj[f"subject_{idx}"] = "A"
if 60 <= item <= 75:
grade_obj[f"subject_{idx}"] = "B"
if 50 <= item <= 60:
grade_obj[f"subject_{idx}"] = "C"
if 40 <= item <= 50:
grade_obj[f"subject_{idx}"] = "D"
if item < 40:
grade_obj[f"subject_{idx}"] = "Fail"
return grade_obj
marks = [float(n) for n in input("enter marks: ").split()]
for k, v in grader(marks).items():
print(f"{k}: {v}")
Similar questions