We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a3ceb5b commit 7c7718eCopy full SHA for 7c7718e
minjeong/Simulation/2025-01-03-[백준]-#25206-너의평점은.py
@@ -0,0 +1,28 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
+# 1. 과목 평점 테이블 (딕셔너리 사용)
5
+rating = {
6
+ "A+": 4.5, "A0": 4.0,
7
+ "B+": 3.5, "B0": 3.0,
8
+ "C+": 2.5, "C0": 2.0,
9
+ "D+": 1.5, "D0": 1.0,
10
+ "F": 0.0
11
+}
12
13
+# 2. 변수 초기화
14
+total_score = 0 # 총 평점 (학점 * 과목 평점의 합)
15
+total_credit = 0 # 총 학점
16
17
+# 3. 과목별 입력 및 평점 계산
18
+for _ in range(20):
19
+ subject, credit, grade = input().split()
20
+ credit = float(credit) # 학점은 소수점으로 변환
21
22
+ if grade != 'P': # P 등급 과목 제외
23
+ total_score += credit * rating[grade]
24
+ total_credit += credit
25
26
+# 4. 전공 평점 계산 및 출력
27
+GPA = total_score / total_credit
28
+print("{:.6f}".format(GPA)) # 소수점 6자리 출력
0 commit comments