60.2k views
3 votes
Calculate the BMI of a person using the formula BMI = ( Weight in Pounds / ( ( Height in inches ) x ( Height in inches ) ) ) x 703 and assign the value to the variable bmi. Assume the value of the weight in pounds has already been assigned to the variable w and the value of the height in inches has been assigned to the variable h. Take care to use floating-point division.

SUBMIT
1 of 4: 2020-05-24 21:05:22 - W2 of 4: 2020-05-24 21:39:16 - W3 of 4: 2020-05-24 21:54:30 - W4 of 4: 2020-05-24 22:32:18 - W
#python program to compute BMI
print("Enter weight in pounds:")
w = float(input())
print("Enter height in inches:")
h = float(input())
bmi = w / (h * h) * 703
print("BMI = " + str(bmi))

User Bertha
by
4.5k points

1 Answer

0 votes

Answer:

See Explanation

Step-by-step explanation:

Your program is correct.

However, it's best to control your output (especially when it involves decimals) by rounding up to some decimal places.

So, I'll rewrite the program as follows (See comments for explanation)

#Prompt user for weight

w = float(input("Enter weight in pounds: "))

#Prompt user for height

h = float(input("Enter height in inches: "))

#Calculate BMI

bmi = w / (h * h) * 703

#Print BMI and round up to 2 decimal places

print("BMI = " + str(round(bmi,2)))