0
Can someone please explain to me what exactly I did wrong? I'm probably just missing something (Python)
11 Réponses
+ 1
The input should be fine like this:
Weight= input(float())
Height = input(float())
if bmi < 18.5:
print ("Underweight")
elif (bmi => 18.5 and < 25):
print ("Normal")
elif (bmi > 25 and < 30):
print ("Overweight")
else:
print ("Obese")
+ 3
Hey LOL CLOWN
1.Take weight as float !
2.missing colon at if statement
3. don't write => that's error write >=
4.write BMI>=18.5 and BMI<25 (BMI must come two times for condition)
+ 1
You missing colon(:) and also there is wrong indentation
+ 1
Here is corrected code there was lot of errors in yours
+ 1
Yeah don't afraid of making mistake but make sure you should not repeat mistake. Good luck
+ 1
LOL CLOWN
Try this:
#your code goes here
weight = int(input());
height = float(input());
bmi = weight/float(height*height);
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')
+ 1
weight = input()
height = float(input())
heightsquare = float(height * height)
bmi = float(float(weight )/ heightsquare)
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")
0
Thanks for the help. I made weight a float variable and put colon. Can you explain what's indentation ? Also is there something wrong with my first if clause?
0
weight = float(input())
height = float(input())
heightsquare = float(height * height)
bmi = float(weight / heightsquare)
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 ("Obese")
0
Sorry for the errors, I'm new here. I think I'll keep missing colons here and there and what not. Thanks for all the help
- 1
Hey Spooderman and YUGRAJ
Don't send answers , let them try themselves , how will they improve .Yes you have solved code but don't give next time.