Program to Calculate Body Mass Index (BMI)

The Body Mass Index (BMI) or Quetelet index is a value derived from the mass (weight) and height of an individual, male or female. The BMI is defined as the body mass divided by the square of the body height and is universally expressed in units of kg/m2, resulting from the mass in kilograms and height in meters. The formula is:

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

Examples:

Input : height(in metre): 1.79832
weight(in Kg): 70
Output : The BMI is 21.64532402096181, so Healthy.
Explanation : 70/(1.79832*1.79832)

Input : height(in metre): 1.58496
weight(in Kg): 85
Output : The BMI is 33.836256857260594 so Suffering from Obesity
Explanation : 70/(1.58496*1.58496)

filter_none

edit
close

play_arrow

link
brightness_4
code

#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")

chevron_right


Output:

The BMI is 21.64532402096181 so Healthy


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.