알고리즘
[ Python ] 코드업 1229
mminky
2021. 6. 14. 11:24
728x90
* 문제
https://codeup.kr/problem.php?id=1229
비만도 측정 2
키 h와 몸무게 w가 공백을 기준으로 실수로 입력된다.(1≤w, h≤200) 반드시 double형을 사용해야 함. float으로 하면 오답처리되는 케이스가 있음.
codeup.kr
[ 코드 ]
def stand_weight(h):
if h<150:
sw=h-100
elif 150<=h<160:
sw=(h-150)/2 +50
elif h>=160:
sw=(h-100)*0.9
return sw
#비만도
def overweight(w,sw):
over=(w-sw)*100/sw
return over
def grade(h,w):
sw = stand_weight(h)
over = overweight(w,sw)
if(over <= 10):
print('정상')
elif(10<over<=20):
print('과체중')
elif(over>20):
print('비만')
#main
h,w=map(float,input().split())
grade(h,w)
파이썬에서는 float해도 오류가 안나는 것 같다!
(double형이 없어서 그런가?)
[ 결과 ]
반응형