본문 바로가기
코딩 테스트/백준

[백준 9498번] 시험 성적 (python)

by SH_L 2023. 8. 13.
반응형

[문제]

 

 

 

 

[풀이]

 

score = int(input())

if score >= 90 and score <= 100:
    print("A")
    
elif score >= 80 and score <= 89:
    print("B")

elif score >= 70 and score <= 79:
    print("C")

elif score >= 60 and score <= 69:
    print("D")

else:
    print("F")

 

int(input())을 사용하여 입력받은 값을 변수 score에 저장한다.

 

if와 elif를 순서대로 사용하여 각 조건별로 출력되는 값을 다르게 작성한다.

반응형