Skip to content
Related Articles

Related Articles

Improve Article

Program to Calculate Body Mass Index (BMI)

  • Difficulty Level : Medium
  • Last Updated : 29 May, 2021

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 meter): 1.79832
weight(in Kg): 70
Output : The BMI is 21.64532402096181, so Healthy.
Explanation : 70/(1.79832*1.79832)

Input : height(in meter): 1.58496
weight(in Kg): 85
Output : The BMI is 33.836256857260594 so Suffering from Obesity
Explanation : 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")

Output: 
 



The BMI is 21.64532402096181 so Healthy

 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :