小明身高1.75,体重80.5kg。请根据BMI公式(体重除以身高的平方)帮小明计算他的BMI指数,并根据BMI指数:
用if-elif
判断并打印结果:
#_*_coding:utf-8_*_
w = raw_input(‘plaese input your weight: ‘)
h = raw_input(‘plaese input your height: ‘)
height = float(h)
weight = float(w)
bmi = weight/(height*height)
if bmi <= 18.5:
print(‘underweight‘)
elif 18.5<bmi<=25:
print(‘normal‘)
elif 25<bmi<=28:
print(‘overweight‘)
elif 28<bmi<=32:
print(‘fat‘)
else:
print(‘too fat‘)
原文:http://www.cnblogs.com/my-907247607-blogs/p/5293957.html