Python Program to Calculate Body Mass Index (BMI)

Body Mass Index (BMI) is a numerical value calculated based on a person’s weight and height. It helps determine whether a person is underweight, normal weight, overweight, or obese.

BMI Formula:

\[\text{BMI} = \frac{\text{weight (kg)}}{\text{height (m)}^2}\]

In this tutorial, we will write a Python program to calculate BMI and classify the result into different categories.

Python Program to Calculate BMI

# Taking user input
weight = float(input("Enter your weight in kg: "))
height = float(input("Enter your height in meters: "))

# Calculating BMI
bmi = weight / (height ** 2)

# Determining BMI category
if bmi < 18.5:
    category = "Underweight"
elif 18.5 <= bmi < 24.9:
    category = "Normal weight"
elif 25 <= bmi < 29.9:
    category = "Overweight"
else:
    category = "Obese"

# Displaying the results
print(f"Your BMI is: {bmi:.2f}")
print(f"Category: {category}")

Output

Enter your weight in kg: 60
Enter your height in meters: 1.76784
Your BMI is: 19.20
Category: Normal weight
Share your love
Subhankar Rakshit
Subhankar Rakshit

Hey there! I’m Subhankar Rakshit, the brains behind PySeek. I’m a Post Graduate in Computer Science. PySeek is where I channel my love for Python programming and share it with the world through engaging and informative blogs.

Articles: 194