# Exercise program in Python
# Define a function to calculate BMI
def calculate_bmi(weight, height):
bmi = weight / (height ** 2)
return bmi
# Define a function to determine BMI category
def determine_category(bmi):
if bmi < 18.5:
return "Underweight"
elif bmi < 25:
return "Normal weight"
elif bmi < 30:
return "Overweight"
else:
return "Obese"
# Prompt user to enter weight in kg and height in meters
weight = float(input("Enter your weight in kg: "))
height = float(input("Enter your height in meters: "))
# Calculate BMI and determine category
bmi = calculate_bmi(weight, height)
category = determine_category(bmi)
# Print results
print("Your BMI is:", bmi)
print("Your BMI category is:", category)
Comments
Post a Comment