#BOJ 25206 너의 평점은
grade_scale = {'A+':4.5, 'A0':4.0, 'B+':3.5, 'B0':3.0, 'C+':2.5, 'C0':2.0, 'D+':1.5, 'D0':1.0, 'F':0.0}
total_unit = 0
total_grade = 0
for _ in range(20):
course, unit, grade = input().split()
unit = float(unit)
if grade != 'P':
total_unit += unit
total_grade += unit*grade_scale.get(grade)
print(total_grade / total_unit)
💡 딕셔너리 자료형
{Key1:Value1, Key2:Value2, Key3:Value3, ...}
키로 value 얻기
a = {'name':'pey', 'phone':'010-9999-1234', 'birth': '1118'}
에서 pey
를 얻고 싶을 때
1. a.get('name')
2. a['name']