I created a BMI calculator using python, is it correct ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I created a BMI calculator using python, is it correct ?

w=int(input("W")) h=float(input("H")) b=(w)/(h*h) while b<18.5: print("Underweight") break while b<25: if b>=18.5: print("Normal") break while b<30: if b>=25: print("Overweight") break if b>30: print("Obesity")

19th May 2021, 3:20 PM
Viren Shah
Viren Shah - avatar
7 Answers
+ 2
w=int(input()) h=float(input()) b=w/(h**2) if (b<18.5): print("Underweight") if (b>=18.5 and b<25): print("Normal") if (b<30 and b>=25) : print("Overweight") if b>=30: print("Obesity")
4th Sep 2021, 5:49 AM
Viren Shah
Viren Shah - avatar
+ 3
Why to use loops when it can be done through if else
19th May 2021, 4:10 PM
Atul [Inactive]
+ 3
My pleasure
19th May 2021, 5:28 PM
Atul [Inactive]
+ 1
Done, thanks atul
19th May 2021, 5:19 PM
Viren Shah
Viren Shah - avatar
+ 1
Viren Shah am also facing same problem, any solution???
31st Aug 2021, 12:37 PM
Sandeepkumar Arisella
Sandeepkumar Arisella - avatar
0
Hi! If you pass all tests, then yes, its correct
19th May 2021, 3:38 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
On vs code software it is running but, while solving it in sololearn project in python for beginners course, it's saying error. I am confused
19th May 2021, 3:51 PM
Viren Shah
Viren Shah - avatar