M-00016.py 학생 점수 등급 분류 (수·우·미·양·가)

10 P
QUESTION 16 #714
20명 점수를 5개 구간으로 나눠 인원 수를 셉니다. 빈칸에 들어갈 알맞은 누적식을 채우세요.
main.py
score = [64, 89, 100, 85, 77, 58, 79, 67, 96, 87,
         87, 36, 82, 98, 84, 76, 63, 69, 53, 22]

count_su = 0
count_woo = 0
count_mee = 0
count_yang = 0
count_ga = 0

i = 0
while i < len(score) :
    if score[i] >= 90 and score[i] <=100 :
        

    if score[i] >= 80 and score[i] <= 89 :
        count_woo += 1

    if score[i] >= 70 and score[i] <= 79 :
        count_mee += 1

    if score[i] >= 60 and score[i] <= 69 :
        count_yang += 1

    if score[i] >= 0 and score[i] <= 59 :
        count_ga += 1

    i += 1

print("수 : %d명" % count_su)
print("우 : %d명" % count_woo)
print("미 : %d명" % count_mee)
print("양 : %d명" % count_yang)
print("가 : %d명" % count_ga)
실행 결과 예시
수 : 3명
우 : 5명
미 : 4명
양 : 4명
가 : 4명
INTERACTIVE SHELL Shift + Enter 로 즉시 실행