로그인 바로가기 하위 메뉴 바로가기 본문 바로가기

모두를 위한 프로그래밍 : 파이썬

임시 이미지 커넥트재단 edwith
http://www.edwith.org/pythonforeverybody/forum/21599
좋아요 2776 수강생 48860

#Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error.
#If the score is between 0.0 and 1.0, print a grade using the following table:
#Score Grade >= 0.9 A >= 0.8 B >= 0.7 C >= 0.6 D < 0.6 F
#If the user enters a value out of range, print a suitable error message and exit. For the test, enter a score of 0.85.

sc = input("Enter score: ")
score = float(sc)

try:
score >=0.0 and score <= 1.0
except:
print("A value is out of range")
quit()

if score >= 0.9 :
print("A")
elif score >= 0.8 :
print("B")
elif score >= 0.7 :
print("C")
elif score >= 0.6 :
print("D")
else :
print("F")

 

수업에서 다루지는 않았지만 문제가 있어서 풀어봤는데 1.5를 넣어도 계속 A가 나오는 이유가 뭘까요?