About Lesson
Features:
-
Take user input: name, subject marks (Math, Science, English, etc.)
-
Calculate average
-
Display formatted report card
-
Use functions, conditionals, and dictionaries
Features:
Take user input: name, subject marks (Math, Science, English, etc.)
Calculate average
Display formatted report card
Use functions, conditionals, and dictionaries
def get_grade(avg):
if avg >= 90:
return "A"
elif avg >= 75:
return "B"
elif avg >= 60:
return "C"
else:
return "F"
student = {}
student["name"] = input("Enter student name: ")
student["math"] = int(input("Math marks: "))
student["science"] = int(input("Science marks: "))
student["english"] = int(input("English marks: "))
total = student["math"] + student["science"] + student["english"]
avg = total / 3
grade = get_grade(avg)
print(f"nReport Card for {student['name']}")
print(f"Average: {avg:.2f} | Grade: {grade}")