BMI CALCULATOR (PYTHON BEGINNER PROJECT) | Sololearn: Learn to code for FREE!

+8

# BMI CALCULATOR (PYTHON BEGINNER PROJECT)

Tracking your BMI is a useful way of checking if you’re maintaining a healthy weight. It’s calculated using a person's weight and height, using this formula: weight / height² The resulting number indicates one of the following categories: Underweight = less than 18.5 Normal = more or equal to 18.5 and less than 25 Overweight = more or equal to 25 and less than 30 Obesity = 30 or more Let’s make finding out your BMI quicker and easier, by creating a program that takes a person's weight and height as input and outputs the corresponding BMI category. Sample Input 85 1.9 Sample Output Normal Here is the code I have written pls fix the error And give the solution https://code.sololearn.com/cu0ilSYmD8Df/?ref=app

2/4/2021 6:14:39 AM

+128

weight = int(input()); height = float(input()); x = weight/float(height*height); if x < 18.5: print('Underweight') if x>=18.5 and x<25: print("Normal") if x >= 25 and x < 30: print('Overweight') if x >= 30: print('Obesity')

+20

#Here is the way #your code goes here weight=float(input()) height=float(input()) bmi= weight/(height)**2 if bmi<18.5: print("Underweight") elif bmi>=18.5 and bmi<25: print("Normal") elif bmi>=25 and bmi<30: print("Overweight") else: print("Obesity")

+9

weight = int(input()); height = float(input()); bmi = weight/float(height*height); if bmi < 18.5: print('Underweight') elif bmi>=18.5 and bmi<25: print("Normal") elif bmi >= 25 and bmi < 30: print('Overweight') else: print('Obesity')

+5

weight = float(input()) height = float(input()) BMI = weight / (height ** 2) if BMI < 18.5: print('Underweight') elif 18.5 <= BMI < 25: print("Normal") elif 25 <= BMI < 30: print("Overweight") elif BMI > 30: print('Obesity')

+4

h=52 """int(input("enter ur hieght"))""" w=1.85 """"int(input("enter ur hieght"))""" bmi=w/(h**2) if bmi>=30: print("obisty") elif bmi<=25: print("over weight") elif bmi <=18.5: print("normal") else: print("under wieght what’s wrong here ?

+4

BEST CODE: weight = int(input()) height = float(input()) age = int(input()) x = weight // (height ** 2) if x < 18.5: print ("Underweight") elif x <= 24.9: print ("Normal") elif x <= 29.9: print ("Overweight") else: print ("Obesity")

+4

weight = int(input()) hight = float(input()) bmi = weight / hight ** 2 if bmi <= 18.5: print('Underweight') if bmi >= 18.5 and bmi <= 25: print('Normal') if bmi >= 25 and bmi <= 30: print("Overweight") if bmi >= 30: print('Obesity')

+3

#your code goes here weight=int(input()) height=float(input()) BMI=weight/height**2 if BMI<18.5: print("Underweight") elif BMI>=18.5 and BMI<25: print("Normal") elif BMI>=25 and BMI<30: print("Overweight") else: print("Obeise") what's wrong?

+2

+2

wheight=int(input()) heigt=float(input()) x=wheight/float(heigt**2) if x<18.5: print("Underwheight") if x>=18.5 and x<25: print("normal") if x>= 25 and x< 30: print("overwheight") if x>=30: print("obesity") IN AN IDE WORKS BUT IN SOLOLEARN NO WHY?

+1

Can anyone explain what is the bug here

+1

weight = int(input('Weight: ')) #Enter your Weight height = float(input('Height: ')) #Enter your Height bmi = weight/float(height**2) #This is the calculator print('BMI: '+str(bmi)) #Print your BMI if bmi < 18.5: #Condition if your bmi is less than 18.5 print('Underweight') elif bmi>=18.5 and bmi<25: #Condition if your bmi > 18.5 and < 25 print("Normal") elif bmi >= 25 and bmi < 30: #Condition if you bmi > 25 and < 30 print('Overweight') else: #Condition print('Obesity')

+1

weight = int(input()); height = float(input()); x = weight/float(height*height); if x < 18.5: print('Underweight') if x>=18.5 and x<25: print("Normal") if x >= 25 and x < 30: print('Overweight') if x >= 30: print('Obesity')

+1

#your code goes here wt=int(input()) ht=float(input()) res=wt / float (ht * ht) if res < 18.5: print("Underweight") elif res>=18.5 and res<25: print("Normal") elif res>=25 and res<30: print("Overweight") else: print("Obesity") Remember that first letter of Underweight,Normal,Overweight,Obesity should be capital or else testcase fails.

+1

w = int(input()) h = float(input()) bmi = w/float(h*h) if bmi < 18.5: print("Underweight") if bmi >=18.5 and bmi <25: print("Normal") if bmi >= 25 and bmi < 30: print('Overweight') if bmi >= 30: print('Obesity')

+1

print("\n---------------------------------------") height = float(input("Please enter your height(cm): ")) / 100 weight = float(input("Please enter your weight(kg): ")) BMI = round((weight/(height ** 2)), 2) w_min = round(18.5 * (height ** 2)) w_max = round(24.99 * (height ** 2)) if BMI < 18.5: print(f"*\nBMI: {BMI} (Under weight)\nYour normal weight should be {w_min}-{w_max} kg") elif BMI >= 18.5 and BMI < 25: print(f"*\nBMI: {BMI} (Normal)\nnormal weight should be {w_min}-{w_max} kg") elif BMI >= 25 and BMI < 30: print(f"*\nBMI: {BMI} (Over weight)\nYour normal weight should be {w_min}-{w_max} kg") elif BMI >= 30 and BMI < 35: print(f"*\nBMI: {BMI} (Obese)\nYour normal weight should be {w_min}-{w_max} kg") elif BMI >= 35: print(f"*\nBMI: {BMI} (Extremely Obese)\nYour normal weight should be {w_min}-{w_max} kg") print("---------------------------------------\n")

+1

#your code goes here weight = int(input()) height = float(input()) result=weight/height**2 if result < 18.5 : print ("Underweight") if result >= 18.5 and result < 25 : print ("Normal") if result >= 25 and result < 30 : print ("Overweight") if result >= 30 : print ("Obesity")

0

Wow u r so cool thanks a lot

0

But can u explain why my code doesn't work?

0

What Ezra Bridger 2207 meant was the first occurrence of < So change BMI<=25 to BMI>=25 General advice: - last branch should normally be else - if you choose your order of checks wisely you need to check only one bound per branch if BMI < 18.5: print("Underweight") elif BMI < 25: print("Normal") elif BMI < 30: print("Overweight") else: print("Obesity")