[BOJ / Python] 25206 너의 평점은

도니·2023년 4월 6일
0

BOJ / Python

목록 보기
42/104
post-thumbnail

문제

백준 25206 너의 평점은

코드

#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']

[참고자료] 점프 투 파이썬 - 딕셔너리 자료형

profile
안녕하세요, 🌱새싹개발자 도니💡입니다!

0개의 댓글

관련 채용 정보