calculate BMI score in python

In this example, you will learn to calculate body mass index in python.

BMI stands for Body Mass Index. Based on the BMI of the individual, it will print a statement stating the overall health of the person.

Syntax :

BMI = weight / (height/100)**2

As per syntax we need to parameter by user which is height and weight. Then we will apply those input to our formula and calculate BMI.

Lastly we will print message according to BMI classification.

Example : Check BMI

# Program to calculate BMI
height = float(input("Enter your height in cm: "))
weight = float(input("Enter your weight in kg: "))

bmi = weight / (height/100)**2

print("You BMI  is :: ",bmi)

if bmi <= 18.4:
    print("You are underweight.")
elif bmi <= 24.9:
    print("You are healthy.")
elif bmi <= 29.9:
    print("You are over weight.")
elif bmi <= 34.9:
    print("You are severely over weight.")
elif bmi <= 39.9:
    print("You are obese.")
    print("You are severely obese.")

Output :

Enter your height in cm: 190.5
Enter your weight in kg: 93.050
You BMI is ::  25.640495725435894
You are over weight.

Here, we will take user input (height and weight) and store it into float then we will calculate BMI and lastly, we will print the appropriate message based on BMI score.

Share your thoughts

Ask anything about this examples