+ 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 ответов
+ 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