Logic Building
# Take inputs
weight = float(input("Enter weight (kg): "))
height = float(input("Enter height (m): "))
# Calculate BMI
bmi = weight / (height ** 2)
# Categorize
if bmi < 18.5:
category = "Underweight"
elif bmi < 25:
category = "Normal"
elif bmi < 30:
category = "Overweight"
else:
category = "Obese"
print(f"BMI: {bmi:.2f}")
print(f"Category: {category}")Output
Enter weight (kg): 70 Enter height (m): 1.75 BMI: 22.86 Category: Normal
Calculate BMI and assign category.
Key Concepts:
- BMI = weight / height²
- Check ranges for categories
- Use elif chain