Could you please help me with my project?
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
1/16/2022 12:39:21 PM
Sajjad
7 Answers
New AnswerI think you should not round BMI. Try this (I changed your code a bit): 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") else: print("Obesity")
This is how you should do it: -take input twice and convert it to integer/float -calculate BMI -write if/elif/else and insert there your conditions and the printed message as the output
weight = int(input()) height = float(input()) check_bmi = round (weight / (height **2)) if check_bmi < 18.5: print("Underweight") elif check_bmi >= 18.5 and check_bmi < 25: print("Normal") elif check_bmi >= 25 and check_bmi < 30: print("Overweight") elif check_bmi >= 30: print("Obesity")