728x90
반응형
문제
점수 구간에 해당하는 학점이 아래와 같이 정의되어 있다. 사용자로부터 score를 입력받아 학점을 출력하라.
점수학점
점수 | 학점 |
81~100 | A |
61~80 | B |
41~60 | C |
21~40 | D |
0~20 | E |
>> score: 83
grade is A
내풀이
score = int(input("score :"))
if score > 80:
print("grade is A")
elif 60 < score < 81:
print("grade is B")
elif 40 < score < 61:
print("grade is C")
elif 20 < score < 41:
print("grade is D")
else:
print("grade is E")
결과값
score :2
grade is E
정답
score = input("score: ")
score = int(score)
if 81 <= score <= 100:
print("grade is A")
elif 61 <= score <= 80:
print("grade is B")
elif 41 <= score <= 60:
print("grade is C")
elif 21 <= score <= 40:
print("grade is D")
else:
print("grade is E")
elif 로 다양한 조건을 줄수 있다.
728x90
반응형
'Coding > 초보자를 위한 파이썬 300제' 카테고리의 다른 글
초보자를 위한 파이썬 300제 // 124 list.sort (0) | 2021.01.17 |
---|---|
초보자를 위한 파이썬 300제 // 123 dictionary (0) | 2021.01.15 |
초보자를 위한 파이썬 300제 // 121 upper, lower (0) | 2021.01.15 |
초보자를 위한 파이썬 300제 // 120 dictionary (0) | 2021.01.14 |
초보자를 위한 파이썬 300제 // 119 dictionary (0) | 2021.01.14 |
댓글