题目转载:http://python.wzms.com/s/1/20
题目描述:
输入体重(单位:Kg)和身高(单位:m),计算BMI指数(BMI指数=体重÷身高的平方),如果BMI <18.5,输出“thin!”;如果18.5≤BMI≤25,则输出“normal!”;如果BMI>25,输出“fat!”。
输入格式:
一行两个数,两数之间以一个空格隔开。
输出格式:
一个字符串
代码:
weight, height = (input('请输入体重、身高:').split())
weight = float(weight)
height = float(height)
BMI_index = weight / height
if BMI_index < 18.5:
print('thin!')
elif BMI_index <= 25:
print('normal!')
else:
print('fat!')
运行结果: