diff --git a/BMI calculator b/BMI calculator new file mode 100644 index 0000000..c7ebe1a --- /dev/null +++ b/BMI calculator @@ -0,0 +1,35 @@ +def calculate_bmi(weight, height): + """Calculate and return the BMI.""" + bmi = weight / (height ** 2) + return bmi + +def get_bmi_category(bmi): + """Determine the BMI category based on the BMI value.""" + 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" + +def main(): + print("Welcome to the BMI Calculator!") + + # Get user input for 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) + + # Get BMI category + category = get_bmi_category(bmi) + + # Display the result + print(f"Your BMI is: {bmi:.2f}") + print(f"You are classified as: {category}") + +if __name__ == "__main__": + main()