+ 3

Can someone please help me with 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 Normal

18th Feb 2022, 9:49 AM
Essien Bukola
Essien Bukola - avatar
19 Answers
+ 4
Hi HungryTrade , I see, you are right ๐Ÿ‘ Thanks for clearence
19th Feb 2022, 10:32 AM
SoloilSole
SoloilSole - avatar
+ 4
Thank you so much guys, I've cleared the bugs
19th Feb 2022, 11:39 AM
Essien Bukola
Essien Bukola - avatar
+ 3
Essien Bukola Hi, SoloLearn accepts 2 inputs, there is no doubt. So you don't need to go anywhere else to try your code. In your if statement, there you didn't add the values in between. For example when a value < 25 it is also < 18,5 right? what will your code execute in such a situation, think it carefully again. Hope this clue helps, have fun with coding :)
19th Feb 2022, 10:02 AM
SoloilSole
SoloilSole - avatar
+ 2
This is my code so far w=int(input()) h=float(input()) Bmi=(w/h**2) if Bmi <18.5: print("Underweight") elif(Bmi <=25): print("Normal") elif(Bmi <=30): print("Overweight") elif(Bmi >=30): print("Obese"
18th Feb 2022, 10:27 AM
Essien Bukola
Essien Bukola - avatar
+ 2
You can try https://jupyter.org/try then click on "Jupyter Notebook", a window will load and then you can create different notebooks and in each notebook you can directly type python and running it without install Python environment. This is an application that you also can download and use directly on your computer. You may find some tutorial of How to use, online.
18th Feb 2022, 10:49 AM
Geoffrey L
Geoffrey L - avatar
+ 2
Geoffrey L {seems that SoloLearn doesn't accept 2 inputs} that isn't correct, for two inputs in "code bits" you use the enter key between inputs, then press submit. For "code challenge" the playground will send two values (or more in other challenges) to your code. Essien Bukola your code is close. Does it pass all the test cases? EDIT: {You may need to read the instructions again, you are close but your logic is including some values that should be in the next group. Also, check your outputs, one isn't 100% match for the expected output.}
18th Feb 2022, 11:42 AM
HungryTradie
HungryTradie - avatar
+ 2
Also, I think they expect you to have the full word. So just printing 'Obese' isn't enough.
19th Feb 2022, 3:22 PM
Bubble Tea
Bubble Tea - avatar
+ 2
G'day Jackie well done for solving it so neatly. We try to not publically post the answers to SoloLearns learning challenges. Also, did you see my thing about "tearing off values"? Your code starts with tearing off anything bigger than 30. โœ… Remaining values must be <=30. So the next elif will not get to check any values bigger than 30 (so no need to ๐Ÿ‘‰<30 and๐Ÿ‘ˆ). It isn't a big problem, but does make your code even more elegant. ๐Ÿ’ƒ๐Ÿ•บ
17th Mar 2022, 12:14 AM
HungryTradie
HungryTradie - avatar
+ 1
What have you try so far?
18th Feb 2022, 9:54 AM
Geoffrey L
Geoffrey L - avatar
+ 1
G'day Gunessina the if - elif chain is ok to catch the values in between because it is eliminating the lower values as it progresses to the next. I mean, ๐Ÿ‘‰if (Bmi <18.5):๐Ÿ‘ˆ catches all smaller values, so the next elif won't have any values less than 18.5, ok? Essien Bukola used some inaccurate logic, it needs ๐Ÿ‘‰elif (Bmi <25):๐Ÿ‘ˆ because =25 should be in the next group. The next elif statement is also incorrectly catching =30 when the question says equal to 25 and less than 30....
19th Feb 2022, 10:19 AM
HungryTradie
HungryTradie - avatar
+ 1
So this is the answer to the question: BMI=0 weight=float(input()) #weight in Kg height=float(input()) #height in M 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")
19th Feb 2022, 3:20 PM
Bubble Tea
Bubble Tea - avatar
+ 1
The question asks both larger and equal to.
20th Feb 2022, 11:19 AM
Bubble Tea
Bubble Tea - avatar
0
Essien Bukola, I think the only "error" is the missing ")" at the end of your code. It seems that Sololearn doesn't accept 2 inputs. I just try your code on another website and it works.
18th Feb 2022, 10:39 AM
Geoffrey L
Geoffrey L - avatar
0
Oh really? That's great. Seems sololearn has some hidden principles. What website was that?
18th Feb 2022, 10:42 AM
Essien Bukola
Essien Bukola - avatar
0
Geoffrey L, yes.. it passes all the test cases except one
19th Feb 2022, 11:36 AM
Essien Bukola
Essien Bukola - avatar
0
Essien Bukola congratulations! Yes, you need to copy the output exactly, spelling, punctuation, and capital letters must match. I copy+paste the instructions into my challenge code, then I cut+paste the words into my output lines. You definitely don't need the and in your elif statements, because you are checking from smallest to largest. Try this ๐Ÿ‘‰elif BMI <25:๐Ÿ‘ˆ Think of the if-elif as tearing off parts of a paper list, the condition chooses where to cut, the previous part is already gone.
19th Feb 2022, 8:31 PM
HungryTradie
HungryTradie - avatar
0
weight =float(input()) height=float(input()) bmi= weight /(height * height ) if bmi > 30: print ("Obesity") elif bmi < 30 and bmi >=25: print ("Overweight") elif bmi < 25 and bmi >=18.5: print ("Normal") elif bmi < 18.5: print ("Underweight")
16th Mar 2022, 9:11 PM
Jackie
Jackie - avatar
0
Change if bmi >= 30: Then its perfect
17th Mar 2022, 12:28 AM
Jackie
Jackie - avatar