+ 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")

19th Mar 2022, 2:15 PM
Mohammad Faysal
Mohammad Faysal - avatar
10 ответов
+ 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.
21st Mar 2022, 9:29 AM
Yusra
Yusra - avatar
+ 3
⚠️input() 👈 remove padding before "elif" and "else".
19th Mar 2022, 2:20 PM
Solo
Solo - avatar
+ 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")
19th Mar 2022, 2:22 PM
Jayakrishna 🇮🇳
+ 2
Jayakrishna🇮🇳 Sorry. I Don't understand.
19th Mar 2022, 2:54 PM
Mohammad Faysal
Mohammad Faysal - avatar
+ 2
Really
19th Mar 2022, 10:40 PM
Ssenyondo Ian
Ssenyondo Ian - avatar
+ 1
Please, explain a little.
19th Mar 2022, 2:22 PM
Mohammad Faysal
Mohammad Faysal - avatar
+ 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
19th Mar 2022, 2:25 PM
Mohammad Faysal
Mohammad Faysal - avatar
+ 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!
21st Mar 2022, 7:11 AM
Julia Marshall
0
Is it not solved Mohammad Faysal ? The above code works fine. Did you checked it?
19th Mar 2022, 2:48 PM
Jayakrishna 🇮🇳
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..?
19th Mar 2022, 2:59 PM
Jayakrishna 🇮🇳