- 1

What is the code to the project of bmi calculator in python 3?

I hv tried multiple times but error occurs everytime

18th May 2021, 10:46 AM
manny p
manny p - avatar
23 Respuestas
+ 13
weight = float(input("85")) height = float(input("1.9")) 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")
18th May 2021, 11:15 AM
manny p
manny p - avatar
+ 4
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")
7th Aug 2021, 6:56 PM
Niranjan S
Niranjan S - avatar
+ 3
weight = float(input("85")) height = float(input("1.9")) BMI = weight/(height**2) if BMI<18.5: print("Underweight") elif BMI>=18.5 and <25: print("Normal") elif BMI>=25 and <30: print("Overweight") else: print("Obesity") See i hv posted the code now.Can u help where i am going wrong?
18th May 2021, 10:58 AM
manny p
manny p - avatar
+ 1
Ohk..thanks! I will remember that next time
18th May 2021, 11:09 AM
manny p
manny p - avatar
+ 1
Just change to weight = float(input()) height = float(input()) As explained by Slick
18th May 2021, 11:21 AM
Aditya
Aditya - avatar
+ 1
Here we go weight = float(input("85")) height = float(input("1.9")) 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")
30th Oct 2022, 7:20 AM
Ahmed Mu'azu Sabo
Ahmed Mu'azu Sabo - avatar
0
I don't want the exact answer.i just want to check where i am going wrong
18th May 2021, 10:49 AM
manny p
manny p - avatar
0
I don't know how sl calculates bmi, so if its a problem with the math, that's on you. BUT, when checking a single value against multiple values in a single if/elif statement use the value to compare both times: BAD: ... elif BMI >= 25 and < 30: ... GOOD: ... elif (BMI >= 25) and (BMI < 30): ... See how the "GOOD" one has the variable in it twice? That's needed if you want to compare it against multiple values
18th May 2021, 11:05 AM
Slick
Slick - avatar
0
Still not working😶
18th May 2021, 11:12 AM
manny p
manny p - avatar
0
post. the. code
18th May 2021, 11:14 AM
Slick
Slick - avatar
0
what is float(input("85")) for??? float() turns stuff into floats input() takes user input thats typed AFTER the program starts when a string is included in input(), for example: choice = input("Enter a choice: ") that string is a prompt, not anything to do w/ the variable. You may need to go over input/output again
18th May 2021, 11:19 AM
Slick
Slick - avatar
0
Got it, thanks slick and Aditya!
18th May 2021, 11:24 AM
manny p
manny p - avatar
0
weight=float(input()) height=float(input()) bmi=weight/(height**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") This was my answer then....try check it out
18th May 2021, 6:41 PM
BAMIDELE AFOLABI
BAMIDELE AFOLABI - avatar
0
Try this: w = int(input()) h = float(input()) bmi = w / (h*h) 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")
19th May 2021, 3:05 AM
Ankush Gauro
0
Thank you that helped so much
10th Nov 2021, 12:16 AM
Abigail Gordon
Abigail Gordon - avatar
0
I solved mine using on if statement no elif or else
19th Mar 2022, 11:16 AM
Ademola Aderogba
Ademola Aderogba - avatar
0
Hello, I wanted to ask if someone can explain to me why my code gave me an error? I tried it in the terminal and it worked perfectly. but here in sololearn it didn't work. so I had to remove the string from the inputs so it could work in sololearn. FIRST CODE (THAT DOES NOT WORK IN SOLOLEARN BUT IT WORKS IN THE TERMINAL): w = float(input("Weight")) h = float(input("Height")) bmi = w/(h**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") SECOND CODE (WHAT IF IT WORKS IN SOLOLEARN AND ALSO IN THE TERMINAL): w = float(input()) h = float(input()) bmi = w/(h**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")
31st Mar 2022, 2:14 PM
Eligio Graterol
0
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') elif bmi > 30: print('Obesity')
27th Jul 2022, 10:01 PM
Alexander Le
Alexander Le - avatar
0
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") Could someone please point out my error? And correct me .... waiting
10th Oct 2022, 6:54 PM
Halimatu Faruk Bello
Halimatu Faruk Bello - avatar
0
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 ('Obesity') ********************************** This is the code I used, I hope it helps
22nd Oct 2022, 2:28 AM
Scott Woten
Scott Woten - avatar