0
BMI Calculator Beginners Python
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
4 odpowiedzi
+ 2
Close, but still quite a few errors.
It looks like you started to get frustrated and then a bit lost.
Try this as an example of your solution.
DM me for a full explanation of any bits you don't understand as I am a bit busy now.
def BMI_Counter(w,h):
BMI = w / (h**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")
weight = float(input())
height = float(input())
BMI_Counter(weight,height)
0
def BMI_Counter(number):
if number < 18.5:
return ("Underweight")
if number >= 18.5 and number <= 25:
return ("normal")
if number >= 25 and number <= 30:
return ("Overweight")
if number >= 30:
return ("Obesity")
if number:
return number
This is what i have so far but im not sure how to incorporate the formula portion.
0
Tyler Richardson
You need to generate a result of the given BMI equation.
1. Create inputs for weight and height. Be careful of sequence so that Sololearn applies correct figures
2. Generate result from equation.
3. Call your function using the result from step 2 as the argument.
IE:
BMI_Counter(85)
0
def BMI_Counter(input):
weight = int(input)
height = float(input)
BMI = weight / (height**2)
if (BMI) < (18.5):
print ("Underweight")
elif (BMI) >= 18.5 and (input) <= 25:
print ("normal")
elif (BMI) >= 25 and (input) <= 30:
print ("Overweight")
else: (BMI) >= 30
print ("Obesity")
return BMI
Rik Wittkopp this is where ive gotten now. Its still not quite working. Any suggestions?