0

Please can someone help me with the code for the python project for beginners "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 ------------------ This is my code ------------------ #your code goes here weight= float(input()) height= float(input()) #h2 = height**2 solve = int(weight/(height**2)) if solve < 18.5: print('Underweight') elif solve >= 18.5 and solve < 25: print('normal') elif solve >= 25 or solve < 30: print('Overweight') elif solve >= 30: print('Obesity') else: print('done')

10th Sep 2021, 4:19 PM
Obikpi Daniel
Obikpi Daniel - avatar
2 Respuestas
+ 1
Obikpi Daniel You have some little mistake. 1 - don't convert solve to int 2 - n should be in caps in normal 3 - for Obesity, solve should be >= 30 Here is solution: #your code goes here weight= float(input()) height= float(input()) #h2 = height**2 solve = weight/(height**2) if solve < 18.5: print('Underweight') elif solve >= 18.5 and solve <= 25: print('Normal') elif solve > 25 and solve <= 30: #mistake was here, should be and instead of or print('Overweight') elif solve > 30: print('Obesity') else: print('done')
10th Sep 2021, 4:23 PM
A͢J
A͢J - avatar
+ 1
Thanks alot bro It worked 👍👍👍
10th Sep 2021, 4:29 PM
Obikpi Daniel
Obikpi Daniel - avatar