29th Jul 2023, 9:24 PM
Edurne
Edurne - avatar
3 Antworten
+ 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") ...
30th Jul 2023, 6:54 AM
Lothar
Lothar - avatar
+ 2
I see a syntax error. There is an unwanted # in front of altura in the second calculation of that line.
29th Jul 2023, 10:43 PM
Brian
Brian - avatar
+ 1
Thank you! Lothar
30th Jul 2023, 9:36 AM
Edurne
Edurne - avatar