10 odpowiedzi
+ 4
Check this out:
#your code goes here
weight=int(input())
height=float(input())
BMI = weight/(height**2)
if BMI <= 18.5:
print("Underweight")
elif BMI <= 25:
print("Normal")
elif BMI <=30:
print("Overweight")
else :
print("Obesity")
+ 2
https://code.sololearn.com/c2s7cmp3Ug4N/?ref=app
Not sure about your error but I think is indentation. Your print statements should be indented to only execute when the condition is true. See my code.
+ 1
BMI Calculator
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
Weight is in kg, height is in meters.
Note, that height is a float.
+ 1
I tried this way but not working
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")
+ 1
I thought both weight and height were suppose to be float when I did this challenge.
0
@Lebi thank you so much
but there why weight is in float? while it says height is in only float
- 1
Whats your error?
Are your code running properly? Is that actual code you are trying?
it is not idented properly... so errors.
save in playground and share link here...
- 1
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')
- 1
w=float(input())
h=float(input())
B=w/(h**2)
if B<18.5:
print("Underweight")
elif B>=18.5 and B<25:
print("normal")
elif B>=25 and B<30:
print("Overweight")
elif B>=30:
print("Obesity")
- 1
w=float(input())
h=float(input())
B=w/(h**2)
if B<18.5:
print("Underweight")
elif B>=18.5 and B<25:
print("normal")
elif B>=25 and B<30:
print("Overweight")
elif B>=30:
print("Obesity")
to solve all 5 cases