计算体重指数(BMI)的程序

这个 体重指数(BMI) 奎特莱特指数 是从个体(男性或女性)的质量(重量)和身高得出的值。BMI的定义是体重除以身高的平方,通常以千克/平方米为单位表示,由以千克为单位的质量和以米为单位的高度得出。公式是:

null
BMI = (mass or weight)/(height*height)where,mass or weight is in Kg,height is in meters

例如:

Input : height(in meter): 1.79832weight(in Kg): 70Output : The BMI is 21.64532402096181, so Healthy.Explanation : 70/(1.79832*1.79832)Input : height(in meter): 1.58496weight(in Kg): 85Output : The BMI is 33.836256857260594 so Suffering from ObesityExplanation : 70/(1.58496*1.58496)

Python3

#Python program to illustrate
# how to calculate BMI
def BMI(height, weight):
bmi = weight / (height * * 2 )
return bmi
# Driver code
height = 1.79832
weight = 70
# calling the BMI function
bmi = BMI(height, weight)
print ( "The BMI is" , format (bmi), "so " , end = '')
# Conditions to find out BMI category
if (bmi < 18.5 ):
print ( "underweight" )
elif ( bmi > = 18.5 and bmi < 24.9 ):
print ( "Healthy" )
elif ( bmi > = 24.9 and bmi < 30 ):
print ( "overweight" )
elif ( bmi > = 30 ):
print ( "Suffering from Obesity" )


输出:

The BMI is 21.64532402096181 so Healthy

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享