Test/Python(20220101~)

Day9_Dictionary, 점수를 가지고 등급 매기는 프로그램

kiostory 2022. 1. 12. 21:04
student_scores = {
  "Harry": 81,
  "Ron": 78,
  "Hermione": 99, 
  "Draco": 74,
  "Neville": 62,
}
# ? Don't change the code above ?
#TODO-1: Create an empty dictionary called student_grades.
student_grades = {}
#TODO-2: Write your code below to add the grades to student_grades.?
for key in student_scores:
    score = student_scores[key]
    if score > 90 and score <=100 :
        student_grades[key] = "Outstanding"
    elif score >80:
        student_grades[key] = "Exceeds Expectations"
    elif score >70:
        student_grades[key] = "Acceptable"
    else:
        student_grades[key] = "Fail"
# ? Don't change the code below ?
print(student_grades)
---------------------------------------------------------
{'Harry': 'Exceeds Expectations', 'Ron': 'Acceptable', 'Hermione': 'Outstanding', 'Draco': 'Acceptable', 'Neville': 'Fail'}