(BMI calculator) Can someone please be kind enough to find the errors in this Python code please.šŸ™ƒšŸ¤“ | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

(BMI calculator) Can someone please be kind enough to find the errors in this Python code please.šŸ™ƒšŸ¤“

Weight= int(input()) height= float (input()) BMI =( weight/height**2) if BMI >=30: print ("obese") elif (BMI>=30 and<=18.5): print("Normal") elif BMI<= 18.5 : print (" Underweight") else : print("Overweight")

22nd Oct 2021, 2:26 PM
Nethmi Pallekankanamge
Nethmi Pallekankanamge - avatar
6 Respostas
+ 7
Nethmi Pallekankanamge , there are many errors in your code: alignment, names of the variables (once weight starts with capital letter, once with lowercase letter), logical errors ( "<" instead of ">" and vice versa), wrong message "obese" instead of "Obesity" etc. Look at the corrected code: weight= int(input()) height= float (input()) BMI =(weight/height**2) if BMI >=30: print ("Obesity") elif (BMI<=25 and BMI>=18.5): print("Normal") elif BMI< 18.5: print ("Underweight") else : print("Overweight")
22nd Oct 2021, 3:06 PM
TheWhĀ”teCat šŸ‡§šŸ‡¬
TheWhĀ”teCat šŸ‡§šŸ‡¬ - avatar
+ 1
Weight should be a float type not int as it is dealing with a float
22nd Oct 2021, 2:31 PM
Kamil Hamid
Kamil Hamid - avatar
+ 1
weight= int(input()) height= float (input()) BMI =( weight/height**2) if BMI >=30: print ("Obesity") elif (BMI<25 and BMI>=18.5): print("Normal") elif BMI< 30 and BMI>=25: print ("Overweight") else : print("Underweight")
22nd Oct 2021, 3:11 PM
Atul [Inactive]
+ 1
Atul [Inactive] thank you for taking the time to answer my question ā˜ŗļø
22nd Oct 2021, 3:27 PM
Nethmi Pallekankanamge
Nethmi Pallekankanamge - avatar
0
Kamil Hamid i changed it ..but it still says thereā€™s an error in indentation and i still cant fix it šŸ™Thanks for the tip btw
22nd Oct 2021, 3:00 PM
Nethmi Pallekankanamge
Nethmi Pallekankanamge - avatar
0
TheWhĀ”teCat šŸ‡§šŸ‡¬ šŸ™Thank you so much for this ,i corrected my code ,now and it finally works!!! šŸ˜ŠāœØThanks a lot again
22nd Oct 2021, 3:26 PM
Nethmi Pallekankanamge
Nethmi Pallekankanamge - avatar