gradeDict = {"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}
sumofgrade=0.0
creditSum=0.0
for i in range(20):
subject, credit, grade =input().split()
if grade=='P':
continue
sumofgrade +=float(credit)*gradeDict[grade]
creditSum+=float(credit)
GPA=sumofgrade/creditSum
print(GPA)
credit에 float형 붙여야함.
'Back-end > 백준(python)' 카테고리의 다른 글
[백준/python] 2566번 최댓값: 2차원 행렬에서 최댓값 찾고 해당 위치(행,열) 출력/ max(map(max, arr)) (1) | 2023.10.24 |
---|---|
[백준/python] 2738번 행렬 덧셈: 행렬의 크기와 원소 받아 2차원 배열 만들기 (1) | 2023.10.24 |
[백준/python] 1316: 그룹 단어 체커/ set(), list(dict.fromkeys()) 차이 (0) | 2023.10.24 |
[백준/python] 2941 크로아티아알파벳 개수 (1) | 2023.10.24 |
★[백준/python] 10809번 알파벳찾기: ord(),chr() 아스키코드값 변환/ for-loop, find() (0) | 2023.10.24 |