BMI calculator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

BMI calculator

In the BMI calculator project of python beginners I get the last two hidden tests wrong, but I don't understand why. Can you help me?

26th May 2021, 3:16 PM
Hi I Am Noob :)
Hi I Am Noob :) - avatar
8 Answers
+ 3
We might help you if you show your attempt to us but without showing your code it's difficult to help you. So please attach the code with the code playground. https://www.sololearn.com/post/75089/?ref=app
26th May 2021, 3:22 PM
The future is now thanks to science
The future is now thanks to science - avatar
0
Post your attempt please
26th May 2021, 7:28 PM
Atul [Inactive]
26th May 2021, 9:01 PM
Hi I Am Noob :)
Hi I Am Noob :) - avatar
0
Is my code
26th May 2021, 9:01 PM
Hi I Am Noob :)
Hi I Am Noob :) - avatar
27th May 2021, 4:43 AM
Eashan Morajkar
Eashan Morajkar - avatar
0
Just some mistakes in the conditions. I have updated it and you will understand the mistakes by comparing this code with your code: https://code.sololearn.com/ca7A141a20a1
31st May 2021, 2:23 PM
The future is now thanks to science
The future is now thanks to science - avatar
0
# Hi I Am Noob :) ypur corrected code should be: peso = float(input()) altura = float(input()) imc = ( peso/( altura**2 ) ) if ( 18.5 > imc ): print("Underweight") if ( 18.5 <= imc < 25 ): print("Normal") if ( 25 <= imc < 30 ): print("Overweight") if ( 30 <= imc ): print("Obesity") """ # this could be simplified to: if imc < 18.5: print("Underweight") elif imc < 25: print("Normal") elif imc < 30: print("Overweight") else: print("Obesity") # in python parenthesis around condition are optional # if..elif..else allow to only test for previously untested values # first if body is executed if imc < 18.5, so next elif..else could assume that 18.5 <= imc # similarly for next conditions... # that's also why final else if present do never take condition ;) """
31st May 2021, 2:43 PM
visph
visph - avatar
- 1
#your code goes here weight = float(input()) height = float(input()) bmi = weight / (height ** 2) if bmi < 18.5: print('Underweight') elif bmi >= 18.5 and bmi < 25: print('Normal') elif bmi >= 25 and bmi < 30: print('Overweight') elif bmi >= 30: print('Obesity') Copy and paste my answer If it is right please vote for me
19th Aug 2021, 7:20 AM
Sariga.S