I have to create a BMI program. The weight should be entered as kilograms and the height as cm, then the program should convert the entered values to imperial equivalents and display them and after it should then calculate the BMI and display the result.
So far I have created a BMI calculator where the user can choose between Metric and Imperial. I have created a while true statement for the user to choose only between metric and imperial and when the user puts the height and the weight it will calculate and then display the result. BUT my problem is that I have to convert the metric values to imperial and I don't know how to do it. I miss the converter for metric to imperial and vice versa, any ideas how to improve it?
while True:
try:
if choice == 'Metric':
weight = float(input('weight in kg:'))
height = float(input('height in cm:'))
if choice == 'Imperial':
weight = float(input('weight in pounds:'))
height = float(input('height in inches:'))
except ValueError:
print('Invalid input')
else:
break
if choice == "Metric":
bmi = weight / (height * height)
return bmi
if choice == "Imperial":
bmi = (weight * 703) / (height * height)
return bmi