What's the problem in the given code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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.")

20th Jun 2021, 9:56 AM
Meet Chudasama
Meet Chudasama - avatar
28 Answers
+ 10
Lines 23, 27 and 31 (the ones after the if statement) need to be indented
20th Jun 2021, 10:07 AM
Lisa
Lisa - avatar
20th Jun 2021, 10:10 AM
A͢J
A͢J - avatar
+ 2
I mean: save code on playground, make public, link it here
20th Jun 2021, 10:00 AM
Lisa
Lisa - avatar
+ 2
Meet Chudasama Don't print unnecessary things. Just print that what problem says. Read problem again and do according to that.
20th Jun 2021, 10:02 AM
A͢J
A͢J - avatar
+ 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
20th Jun 2021, 9:59 AM
Lisa
Lisa - avatar
+ 1
Meet Chudasama Ok then good. Use this formula to calculate BMI. bmi = weight / (height ** 2)
20th Jun 2021, 10:04 AM
A͢J
A͢J - avatar
+ 1
Ohh i gotta it
20th Jun 2021, 10:11 AM
Meet Chudasama
Meet Chudasama - avatar
+ 1
Thank you so much for helping me out with this
20th Jun 2021, 10:11 AM
Meet Chudasama
Meet Chudasama - avatar
+ 1
Thank you so much Lisa n Aj Anant
20th Jun 2021, 10:12 AM
Meet Chudasama
Meet Chudasama - avatar
+ 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
20th Jun 2021, 7:30 PM
Pradeep Kumar Chaurasiya
Pradeep Kumar Chaurasiya - avatar
0
Please help me out with this 🙏🏻
20th Jun 2021, 9:56 AM
Meet Chudasama
Meet Chudasama - avatar
0
Sorry what u mean?
20th Jun 2021, 9:59 AM
Meet Chudasama
Meet Chudasama - avatar
20th Jun 2021, 10:03 AM
Meet Chudasama
Meet Chudasama - avatar
0
I know but this one is my personal
20th Jun 2021, 10:03 AM
Meet Chudasama
Meet Chudasama - avatar
0
Project given by sololearn is done
20th Jun 2021, 10:03 AM
Meet Chudasama
Meet Chudasama - avatar
20th Jun 2021, 10:05 AM
Meet Chudasama
Meet Chudasama - avatar
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
20th Jun 2021, 10:36 AM
SammE
SammE - avatar
0
Thnk u so much for imparting knowledge Rostislav Khalillov
20th Jun 2021, 10:45 AM
Meet Chudasama
Meet Chudasama - avatar
0
Indentation is missing!!
20th Jun 2021, 11:11 AM
Anas Dharar
Anas Dharar - avatar
0
Too much "if", "elif" and "else" exist too
20th Jun 2021, 4:19 PM
MarkClark