0
Python for beginners
Bonjour, pour un exercice on me demande de calculer l'IMC, mais je ne comprend pas pourquoi mon code est faux ? Quelqu'un pourrait m'aider please ? weight = float(input('Enter votre poids en kg:')) height = float(input('Entrer votre taille en m:')) imc = weight / (height * height) print('\nimc=', imc) if imc<18.5: print('Underweight') elif 18.5>=imc<25: print('Normal') elif 25>imc<30: print('Overweight') elif imc>30: print('Obesity')
10 Answers
+ 1
Hey there Safia Beaumale,
Firstable, can I answer you in English?
I found some mistakes in your code:
- the second statement, you should change it a bit using this syntax:
elif imc <= 18.5 and imc <25....
Try to change and use this syntax for the other statements too (like the 3rd).
Btw for the code coach, don't need to print the img valuw6.
And just remove the sentences in the input function, just leave it input() because SoloLearn doesn't support this feature (only in web).
Happy coding :D
Codage heureux :D
+ 1
Now it's correct ?
weight = int(input())
height = float(input())
imc = weight / (height * height)
print('imc=', imc)
if imc<=18.5:
print('Underweight')
elif imc>=18.8 and imc<25:
print('Normal')
elif imc>=25 and imc<30:
print('Overweight')
elif imc>30:
print('Obesity')
0
Hello, its my question in english ^^ - for an exercise on me asking to calculate the BMI, but I do not understand why my code is wrong? Could someone help me please?
weight = float (input ('Enter votre poids en kg:')) height = float (input ('Entrer votre taille en m:')) imc = weight / (height * height) print ('\ nimc =', imc ) if imc <18.5: print ('Underweight') elif 18.5> = imc <25: print ('Normal') elif 25> imc <30: print ('Overweight') elif imc> 30: print ('Obesity')
Thanks for your answer but I can't understand the problem now that I used them and ...
weight = float(input('Enter votre poids en kg:'))
height = float(input('Entrer votre taille en m:'))
imc = weight / (height * height)
print('\nimc=', imc)
if imc<18.5:
print('Underweight')
elif imc>=18.8 and imc<25:
print('Normal')
elif imc>=25 and imc<30:
print('Overweight')
elif imc>30:
print('Obesity')
0
Don't need to print imc value anyway.
0
output expect only one string: let input argument empty, and don't output imc ;)
le resultat attendu doit seulement ĂȘtre la chaĂźne de caractĂšres: ne pas mettre d'argument dans la function input, et ne pas afficher l'imc ;)
0
no, don't output imc...
non, n'affichez pas l'imc...
0
J'ai réussi !! Merci beaucoup pour votre aide ! Thank you so much
0
if u are looking for BMI calculator for solving BMI calculator problem then this will help you
https://code.sololearn.com/cYTq69ghI7Kq/?ref=app
you need to write this
weight = float(input())
height = float(input())
you just need to remove THIS THING
print('\nimc=',imc)
and leave the rest part as it is
- 2
Can you write your question with English ?
- 3
Essayé d'utiliser and logical operator au lieu de mettre la condition sous forme directe:
elif 18<= imc and imc<= ....