Write a program that prompts the user to enter their weight (in kilograms) and height (in meters). The program should calculate the Body Mass Index (BMI) using the formula: BMI = weight / (height * height). The program should then classify the BMI into one of the following categories: less than 18.5 - Underweight BMI between 18.5 and 24.9 - Normal weight BMI between 25 and 29.9 - Overweight BMI 30 or greater - Obesity.
Code:
def calculate_bmi(weight, height):
return weight / (height * height)
def classify_bmi(bmi):
if bmi < 18.5:
return "Underweight"
elif 18.5 <= bmi <= 24.9:
return "Normal weight"
elif 25 <= bmi <= 29.9:
return "Overweight"
else:
return "Obesity"
# Prompt the user to enter weight and height
weight = float(input("Enter your weight in kilograms: "))
height = float(input("Enter your height in meters: "))
# Calculate BMI
bmi = calculate_bmi(weight, height)
# Classify BMI
classification = classify_bmi(bmi)
# Display the result
print("Your BMI is:", bmi)
print("Classification:", classification)
0 Comments