+ 2
Why doesn’t run my code? Any wrong?
weight = int(input)) height = float(input)) bmi = weight / (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")
10 Respuestas
+ 3
If , elif, else . It must right below each other. Indentation errors can occured due to this and your code is having slightly marginal issue.
+ 3
⚠️input() 👈
remove padding before "elif" and "else".
+ 3
weight = int( input() ) #input missing ()
height = float(input()) #wrong mismatch braces()
bmi = weight / (height * height)
if bmi < 18.5:
print("Underweight")
elif bmi >= 18.5 and bmi < 25: #wrong idented
print("Normal")
elif bmi >= 25 and bmi < 30: #wrong idented
print("Overweight")
else: #same
print("Obesity")
+ 2
Jayakrishna🇮🇳 Sorry.
I Don't understand.
+ 2
Really
+ 1
Please, explain a little.
+ 1
#Here description#
Plz solve this.
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
+ 1
Jayakrishna🇮🇳 tried to explain the problem in the comments in the text (after the "#" symbols) above. There's a problem with the syntax of how you're reading in the input data, with mismatched parentheses and no empty argument to input. It should look like:
weight=int(input())
Which is not what you have. (It should be similar for height, and doesn't have to be a float, but can be. The result will be a float either way due to division.)
It also looks like your indentation for the "elif" and "else" checks of your if-loop aren't correct - they should be at the same depth as the initial if-loop.
I hope that helps you find the problem!
0
Is it not solved Mohammad Faysal ?
The above code works fine. Did you checked it?
0
You are posted task description in last post. Why? Confused me..
The code I posted is corrected one. Is it not working? I added corrections in comments also.. What is the problem with the code now..?