(Health application: compute BMI) Body mass index (BMI) is a measure of health based on weight. It can be calculated by taking your weight in kilograms and dividing it by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI.Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.
Here is a sample run:
Enter weight in pounds:95.5
Enter height in inches:50
BMI is 26.8573
Health application: compute BMI Program code:
# Prompt the user to enter weight in pounds
weightPounds = float(input("Enter weight in pounds: "))
# Prompt the user to enter height in inches
heightInches = float(input("Enter height in inches: "))
# Convert weight from pounds to kilograms
weight_kg = weightPounds * 0.45359237
# Convert height from inches to meters
height_meters = heightInches * 0.0254
# Calculate the BMI by dividing weight in kilograms by the square of height in meters
bmi = weight_kg / (height_meters ** 2)
# Display the calculated BMI
print("BMI is", '{0:.4f}'.format(bmi))
Executed Output:
Enter weight in pounds: 95.5
Enter height in inches: 50
BMI is 26.8573