0
Why my code ain't working?
w = int( input ()) r = (input()) ra = (r * r) imt = w / ra if (imt) < 18.5: print ("underweight") if (imt) > 18.5 and (imt) < 24.9: print ("normal") if (imt) > 24 and (imt) < 29.9: print ("overweight") if (imt) >= 30: print ("obesity")
5 Antworten
+ 6
You need to use float() for height
The first letter of the output variables should be uppercase
2nd & 3rd conditions are wrong in Russian language.
w = int( input ())
r = float(input())
ra = (r * r)
imt = w / ra
if (imt) < 18.5:
print ("Underweight")
elif (imt) >= 18.5 and (imt) < 25:
print ("Normal")
elif (imt) >= 25 and (imt) < 30:
print ("Overweight")
elif (imt) >= 30:
print ("Obesity")
+ 1
May be your code wants promotion?
+ 1
Это шутка такая!
-Почему мой код не хочет работать?
-Может твой код хочет повышения.. (По должности или заработной платы)
0
In the 2nd line you haven't converted str to int. Also, you have put 2nd, 3rd and 4th 'if' condition under the first one. I think you should better use elif instead of if in 7th and 9th line, and else in 11th line:
w = int( input ())
r = int(input())
ra = r * r
imt = w / ra
if imt < 18.5:
print ("underweight")
elif imt >= 18.5 and imt < 24.9:
print ("normal")
elif imt >= 24 and imt < 29.9:
print ("overweight")
else:
print ("obesity")
0
How?