+ 1
BMI calculator
I need help with this pls (solved)
8 Answers
+ 2
The problem is with the boundaries (numbers that the "answer" will be)
One advice would be to use **elif** instead of multiple **if** statements
You can check out this code: https://code.sololearn.com/cfyn2MRebToR/?ref=app
+ 7
Garfield ,
to see what your issue is, please link your code here.
+ 7
Jacinto Tejera GonzĂĄlez ,
it is better for you to start your own post, otherwise poeple will not get aware of you. please also include your current code in the post.
+ 2
h=float(input("Enter your height in meters: "))
w=float(input("Enter your Weight in Kg: "))
BMI=w/(h*h)
print("BMI Calculated is: ",BMI)
if(BMI>0):
if(BMI<=16):
print("You are very underweight")
elif(BMI<=18.5):
print("You are underweight")
elif(BMI<=25):
print("Congrats! You are Healthy")
elif(BMI<=30):
print("You are overweight")
else:
print("You are very overweight")
else:
print("enter valid details")
Hope it help you
0
Lothar
So far I got this: weight = float(input)
weight/height**2
if x < 18.5:
if x => 18.5 and x < 25:
if x => 25 and x < 30:
if x => 30:
0
def calculate_bmi(weight, height):
# Calculate BMI
bmi = weight / (height ** 2)
# Return the result
return bmi
# Test the function
print(calculate_bmi(weight=80, height=1.8)) # Output: 24.69
print(calculate_bmi(weight=70, height=1.7)) # Output: 24.22
print(calculate_bmi(weight=65, height=1.6)) # Output: 25.39
This function takes two arguments: weight and height, which represent the weight and height of the person, respectively. The function calculates the BMI using the formula BMI = weight / (height^2), and it returns the result.
I hope this helps! Let me know if you have any questions.
0
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")
0
Python if and else explain