So I am trying to calculate BMI which allows user to choose the metric or imperial system. For example if user input metric 1.8 78. The program will calculate base on the system chosen either imperial or metric. However after inputting the formula and also doing the if else statement the output is not showing the result. Need some advice
import sys
len(sys.argv) == 4
#ensure correct str and float is inputted
try:
units = (sys.argv[1])
weight = float(sys.argv[2])
height = float(sys.argv[3])
except (ValueError, IndexError):
print("Your input is invalid!")
#to ensure only 'metric' or 'imperial' is inputted
while True:
units = (sys.argv[1])
if units == ('metric' or 'imperial'):
break
else:
print("Your input is invalid")
#calculations for the bmi
metric_bmi = weight / (height ** 2)
us_bmi = 703*weight/ (height ** 2)
#to check for which system to calculate and the result of the bmi to give the output
if units == 'metric' and metric_bmi == 16:
print("BMI:%.2f" % metric_bmi + "\tSevere Thinness")
elif units == 'metric' and 16 == metric_bmi <17:
print("BMI:%.2f" % metric_bmi + "\tModerate Thinness")
elif units == 'metric' and 17 == metric_bmi < 18.5:
print("BMI:%.2f" % metric_bmi + "\tMild Thinness")
elif units == 'metric' and 18.5 == metric_bmi < 25:
print("BMI:%.2f" % metric_bmi + "\tNormal")
elif units == 'metric' and 25 == metric_bmi < 30:
print("BMI:%.2f" % metric_bmi + "\tOverweight")
elif units == 'metric' and 30 == metric_bmi < 35:
print("BMI:%.2f" % metric_bmi + "\tObese Class I ")
elif units == 'metric' and 35 == metric_bmi < 40:
print("BMI:%.2f" % metric_bmi + "\tObese Class II")
elif units == 'metric' and metric_bmi > 40:
print("BMI:%.2f" % metric_bmi + "\tObese Class III")
else:
print("Your input is invalid!")
if units == 'imperial' and us_bmi == 16:
print("BMI:%.2f" % us_bmi + "\tSevere Thinness")
elif units == 'imperial' and 16 == us_bmi == 16<17:
print("BMI:%.2f" % us_bmi + "\tModerate Thinness")
elif units == 'imperial' and 17 == us_bmi < 18.5:
print("BMI:%.2f" % us_bmi + "\tMild Thinness")
elif units == 'imperial' and 18.5 == us_bmi < 25:
print("BMI:%.2f" % us_bmi + "\tNormal")
elif units == 'imperial' and 25 == us_bmi < 30:
print("BMI:%.2f" % us_bmi + "\tOverweight")
elif units == 'imperial' and 30 == us_bmi < 35:
print("BMI:%.2f" % us_bmi + "\tObese Class I")
elif units == 'imperial' and 35 == us_bmi < 40:
print("BMI:%.2f" % us_bmi + "\tObese Class II")
elif units == 'imperial' and us_bmi > 40:
print("BMI:%.2f" % us_bmi + "\tObese Class III")
else:
print("Your input is invalid!")