(Health application: BMI ) Revise Listing 4.6, ComputeBMI.py, to let users enter their weight in pounds and their height in feet and inches. For example, if a person is 5 feet and 10 inches, you will enter 5 for feet and 10 for inches. Here is a sample run:
Enter weight in pounds: 140
Enter feet: 5
Enter inches: 10
BMI is 20.087702275404553
You are Normal
SOURCE CODE
# Prompt the user to enter weight in pounds
weight = eval(input("Enter weight in pounds: "))
# Prompt the user to enter weight in feets
feets = eval(input("Enter feet: "))
# Converting feets into inches
a = feets * 12
# Prompt the user to enter height in inches
inches = eval(input("Enter inches: "))
# total height
height = a + inches
KILOGRAMS_PER_POUND = 0.45359237
METERS_PER_INCH = 0.0254
# Compute BMI
weightInKilograms = weight * KILOGRAMS_PER_POUND
heightInMeters = height * METERS_PER_INCH
bmi = weightInKilograms / (heightInMeters * heightInMeters)
# Display result
print("BMI is", format(bmi, ".2f"))
if bmi < 18.5:
print("You are Underweight")
elif bmi < 25:
print("You areNormal")
elif bmi < 30:
print("You are Overweight")
else:
print("You are Obese")
OUTPUT
Enter weight in pounds: 140
Enter Feets: 5
Enter inches: 10
BMI is 20.09
You are Normal