[python/파이썬] 백준 BEAKJOON 2754번: 학점 계산
https://www.acmicpc.net/problem/2754
2754번: 학점계산
어떤 사람의 C언어 성적이 주어졌을 때, 평점은 몇 점인지 출력하는 프로그램을 작성하시오. A+: 4.3, A0: 4.0, A-: 3.7 B+: 3.3, B0: 3.0, B-: 2.7 C+: 2.3, C0: 2.0, C-: 1.7 D+: 1.3, D0: 1.0, D-: 0.7 F: 0.0
www.acmicpc.net
1. 문제

2. 정답 및 풀이
score = input()
if score == "A+": print(4.3)
elif score == "A0": print(4.0)
elif score == "A-": print(3.7)
elif score == "B+": print(3.3)
elif score == "B0": print(3.0)
elif score == "B-": print(2.7)
elif score == "C+": print(2.3)
elif score == "C0": print(2.0)
elif score == "C-": print(1.7)
elif score == "D+": print(1.3)
elif score == "D0": print(1.0)
elif score == "D-": print(0.7)
elif score == "F": print(0.0)
제출 결과

이 외에도 딕셔너리를 이용한 코드가 있다고 한다.
'Algorythm > 백준 BEAKJOON' 카테고리의 다른 글
[python/파이썬] 백준 BEAKJOON 2476번: 주사위 게임 (0) | 2023.05.22 |
---|---|
[python/파이썬] 백준 BEAKJOON 16430번: 제리와 톰 (0) | 2023.05.17 |
[python/파이썬] 백준 BEAKJOON 4101번: 크냐? (0) | 2023.05.09 |
[python/파이썬] 백준 BEAKJOON 5337번: 웰컴 (0) | 2023.05.06 |
[python/파이썬] 백준 BEAKJOON 2525번: 오븐 시계 (0) | 2023.05.01 |