+ 1
Can someone tells me what im doing wrong here
In comment
12 Respostas
+ 9
1) You need to use indentations inside the if statements
2) weight = float(int()) is not valid. Use float(input()) as you want to get input and convert it to float
3) else can't have a condition
4) it should be < than 25 (line 7).
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')
+ 7
The thing you're doing wrong is not sharing your code.
+ 6
Phan The
1. Intdentation Error:
if statement:
yourCode
-> causes an error
if statement:
yourCode
-> yourCode belongs now to the if statement
2. = vs ==
= assign a value to a variable
== check if to values are equal
3. check the last else statement. I suggest you to read in the lesson about if else
+ 3
#your code goes here
, corected code read comments.. Just removed errors, may not a complete solution..Phan The
weight = float(input())
height = float(input()) #use input(),not int()
bmi=weight/(height**2)
if bmi < 18.5:
print('Underweight')
elif bmi >= 18.5 and bmi < 25: #use < or <= or ==, not =.
# = assignment operator, not comparision opearator, use <,<=, or ==
print('Normal')
elif bmi >= 25 and bmi < 30:
print('Overweight')
elif bmi >= 30: # missing :
print('Obesity')
+ 3
There were a number of mistakes including indentation and input syntax. Also one operator problem, and invalid ELSE syntax.
Please review adjusted code
#your code goes here
weight = float(input()) # kgs
height = float(input()) # metres
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')
+ 3
^^ Thank
+ 2
Hello Phan The
At the moment your question is incomplete because you need to share your code.
Otherwise we can't help you.
+ 2
Use indentation. The print statements should be inside the if clause, so must be indented.
To read a number use int(input()) or float(input())
The description of the problem you are referring to (BMI calculator) would make it easier to help you
+ 2
Phan The
Single equal (=) used for assignment. To compare values you need to use double equal (==)
+ 2
You don't need these pieces:
"bmi >= 18.5 and"
"bmi >= 25 and"
"bmi >= 30"
They are all redundant. For example, once you've determined that bmi isn't less than 18.5, then it must be greater than or equal to 18.5. No need to test for it.
+ 1
Yep u right
https://code.sololearn.com/c434qoYPCbvh/?ref=app
Can someone ans pls
0
Phan The
Trt this:
#your code goes here
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')