- 3
What's the problem in the given code?
print("Age (2-120) :-") a = int(input()) print(" Weight (kg) :-") w = float(input()) print("Height (m) :-") h = float(input()) x = round(w/float(h*h),4) print("BMI Of Your Body is " + str( x)) if x < 18.5: print ("You Are Underweight.") if x >= 18.5 and x < 25: print("You are Normal.") if x >= 25 and x < 30: print("You Are Overweight. ") if x > 30: print("You Are Obese.")
29 ответов
+ 10
Lines 23, 27 and 31 (the ones after the if statement) need to be indented
+ 3
Meet Chudasama
There is Indentation problem.
https://code.sololearn.com/c2vUjCf2AlAL/?ref=app
+ 2
I mean: save code on playground, make public, link it here
+ 2
Meet Chudasama
Don't print unnecessary things. Just print that what problem says.
Read problem again and do according to that.
+ 1
Hi, can you copy your code in a playground script, so we can test it?
Like this:
https://code.sololearn.com/cUK6Jt1b0wUQ/?ref=app
+ 1
Meet Chudasama
Ok then good. Use this formula to calculate BMI.
bmi = weight / (height ** 2)
+ 1
Ohh i gotta it
+ 1
Thank you so much for helping me out with this
+ 1
Thank you so much Lisa n Aj Anant
+ 1
You are using multiple if conditions but u have used all possible case from -infinity to +infinity . But if you want to multiple if then there should be remaining cases otherwise you have to use if,elif,..,else. So make the last case x>30 as else and above them as elif
0
Please help me out with this 🙏🏻
0
Sorry what u mean?
0
I know but this one is my personal
0
Project given by sololearn is done
0
for an accurate calculation of BMI, I advise you to use this formula:
bmi = float("{0:.2f}".format(weight / (( height / 100) * (height / 100))))
https://code.sololearn.com/cy88y50poPCn/?ref=app
0
Thnk u so much for imparting knowledge Rostislav Khalillov
0
Indentation is missing!!
0
Too much "if", "elif" and "else" exist too