Body Mass Index (BMI) is a measure of body fat based on a person's weight and height. It is used to screen for weight categories that may lead to health problems.
def calculate_bmi(weight, height):
return weight / (height ** 2)
# Taking input for weight and height and calculating BMI
def calculate_and_display_bmi():
weight = float(input("Enter your weight in kilograms: "))
height = float(input("Enter your height in meters: "))
bmi = calculate_bmi(weight, height)
print("Your BMI is:", bmi)
calculate_and_display_bmi()
Enter your weight in kilograms: 68
Enter your height in meters: 1.75
Your BMI is: 22.20408163265306
Enter your weight in kilograms: 80
Enter your height in meters: 1.80
Your BMI is: 24.691358024691358
The function calculate_bmi(weight, height)
calculates the Body Mass Index (BMI) based on the weight and height provided.
The function calculate_and_display_bmi()
takes input for weight and height, calculates BMI using the aforementioned function, and displays the result.