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')

16th Mar 2021, 1:35 PM
Safia Beaumale
Safia Beaumale - avatar
10 odpowiedzi
+ 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
16th Mar 2021, 1:53 PM
Matthew
Matthew - avatar
+ 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')
16th Mar 2021, 3:32 PM
Safia Beaumale
Safia Beaumale - avatar
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')
16th Mar 2021, 3:03 PM
Safia Beaumale
Safia Beaumale - avatar
0
Don't need to print imc value anyway.
16th Mar 2021, 3:24 PM
HBhZ_C
HBhZ_C - avatar
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 ;)
16th Mar 2021, 3:29 PM
visph
visph - avatar
0
no, don't output imc... non, n'affichez pas l'imc...
16th Mar 2021, 3:36 PM
visph
visph - avatar
0
J'ai réussi !! Merci beaucoup pour votre aide ! Thank you so much
16th Mar 2021, 5:06 PM
Safia Beaumale
Safia Beaumale - avatar
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
17th Mar 2021, 7:11 PM
Abhishek Singh
Abhishek Singh - avatar
- 2
Can you write your question with English ?
16th Mar 2021, 1:39 PM
Ramadhani
Ramadhani - avatar
- 3
Essayé d'utiliser and logical operator au lieu de mettre la condition sous forme directe: elif 18<= imc and imc<= ....
16th Mar 2021, 1:53 PM
HBhZ_C
HBhZ_C - avatar