0
IMC problem ,error in line 7,help
BMI Help,detects an error https://code.sololearn.com/cD8Y1fH2ddLT/?ref=app https://code.sololearn.com/cD8Y1fH2ddLT/?ref=app
3 ответов
+ 6
Edurne ,
> the calculation of the bmi is written multiple times in the code. this makes the code more difficult to read. better to do the calculation once and store it in a variable. like this:
peso = int (input())
altura= float (input())
bmi = peso/altura **2
if bmi < 18.5 :
...
> in one of these calculations in the code there is a syntax error: (has to be without space between > and =):
peso/altura**2 < = 29.9 :
^^^
> an other issue are the values used in the conditional statements:
peso/altura**2 <= 29.9 :
^^^^
if bmi is 29.93, it will not be covered, so no output is generated. better to use:
...
elif x >= 18.5 and x < 25:
print("Normal")
elif x >= 25 and x < 30:
print("Overweight")
...
+ 2
I see a syntax error. There is an unwanted # in front of altura in the second calculation of that line.
+ 1
Thank you! Lothar