Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:
BMI = weight x 703 / height^2
where weight is measured in pounds and height is measured in inches.
Python program code:
#The method 'computeBMI' is used to
#calculate a person’s body mass index (BMI)
def computeBMI(weight, height):
bmi = weight * 703 / (height ** 2)
return bmi
#main method
def main():
#Prompt and read the weight and height in pounds
weight = float(input("Enter weight in pounds: "))
height = float(input("Enter height in inches: "))
#Call the method and display output
BMI = computeBMI(weight, height)
print("BMI:", format(BMI, ".2f"))
if __name__ == "__main__":
main()
Executed Output:
Enter weight in pounds: 200
Enter height in inches: 13
BMI: 831.95