+ 1
Python Beginner Question
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 My Code: height = int(input()) weight = (input()) print (weight/ (height**2)) What's wrong?
3 Answers
+ 5
weight needs to be converted to float and you need to give output as in the task description
+ 5
Ogunseye Sodiq Akolade
Read the task description again. You have to print text based on condition. You just printed BMI value.
+ 2
After calculating this,
weight/height**2
You have to check if the calculated value is less than 18.5 (if it is then print 'Underweight')...
If it is more than or equal to 18.5 and less than 25 (if it is then print 'Normal')
...And so on (as written in the question description...
Note: mind the cases!!
I meant don't print 'underweight' in exchange of 'Underweight'.
It would be taken as wrong, you have to output Underweight (see the capitalised 'u')...and do the same for all...