0
Calculating BMI
#whats wrong please help weight = float(input()) height = float((input()) BMI = weight / height * height print(BMI) if BMI < 18.5: print("Underweight") elif (18.5 <= BMI < 25): print("Normal") elif (25 <= BMI < 30): print("Overweight") else: if BMI >= 30: print("Obesity") # #
4 Antworten
+ 5
#whats wrong please help
weight = float(input())
#There is an extra parenthesis
height = float(input())
#You need to use `**` operator instead of `*` since ** operator has higher precedence than *
BMI = weight / height ** 2
#print(BMI)
if BMI < 18.5:
print("Underweight")
elif (18.5 <= BMI < 25):
print("Normal")
elif (25 <= BMI < 30):
print("Overweight")
else:
if BMI >= 30:
print("Obesity")
+ 3
Your comparison statements need to be adjusted.
Example:
elif BMI >= 18.5 < 25: # if BMI is greater than or equal to 18.5 but smaller than 25
+ 2
https://www.sololearn.com/Discuss/2852479/?ref=apphttps://www.sololearn.com/Discuss/2853754/?ref=apphttps://code.sololearn.com/chV1YaLvOQ45/?ref=app
Further, use search bar before asking questions. You will get many questions like this.
+ 1
weight = int(input())
height = float(input())
BMI = weight / (height**2)
if BMI < 18.5:
print("Underweight")
elif BMI >= 18.5 and BMI < 25:
print("Normal")
elif BMI >= 25 and BMI < 30:
print("Overweight")
else:
print("Obesity")