Python: Body MASS Index(BMI) Calculation Using Python-DecodingDevOps

Body MASS Index(BMI) Calculation Using Python-DecodingDevOps

Body mass index is the value derived from the person's height and weight. It is defined as the body mass in kilograms divided by the square of the body height in meters. A BMI of less than 18.5 means that a person is underweight. A BMI of between 18.5 and 24.9 is ideal. A BMI of between 25 and 29.9 is overweight. A BMI over 30 indicates obesity. BMI is used to screen for weight categories it describes the person's weight according to his particular height. It also shows the fatness of weight. In this post i am going to explain how to calculate body mass index(BMI)using python.

Python Code For Body Mass Index -BMI

Here we are using python if elif loop to calculate body mass index(bmi).

height = float(input("Enter height in meters: "))

weight = float(input("Enter weight in kg: "))

bmi = weight/(height**2) 

print("Your BMI is: {0} and you are: ".format(bmi), end='')

if ( bmi < 16):
   print("severely underweight")

elif ( bmi >= 16 and bmi < 18.5):
   print("underweight")

elif ( bmi >= 18.5 and bmi < 25):
   print("Healthy")

elif ( bmi >= 25 and bmi < 30):
   print("overweight")

elif ( bmi >=30):
   print("severely overweight")

STEP 1: In this step, we first give the inputs for the height and weight of a particular person.

STEP 2: In this step, we calculate the BMI using the formula BMI = weight / height **2. ** operator is used to calculating the power of the height.

STEP 3: In this step, using python if loop if BMI <16 print severely underweight.

STEP 4: In this step, using python if loop if BMI between 16 and 18.5 print underweight.

STEP 5:  In this step, using python if loop if BMI between 18.5 and 25 print healthy.

STEP 6:  In this step, using python if loop if BMI 25 AND 30  print overweight.

STEP 7:  In this step, using python if loop if BMI is greater than 30 print severely overweight.

OUTPUT:

Enter height in meters: 1.75

Enter weight in kilograms: 64

you're BMI is 20.8979 and you are: healthy

 

Leave a Reply

Your email address will not be published. Required fields are marked *