BMI Calculator
Easy
23
3
84.7% Acceptance
In this lab, you are tasked with creating a Python function named calculate_bmi
to calculate the Body Mass Index (BMI) based on a person's height in centimeters and weight in kilograms.
Function Requirements:
- Input Parameters:
height
(in centimeters)weight
(in kilograms)
- Output:
- A tuple
(bmi_value, category)
bmi_value
should be the BMI, calculated asweight (kg) / (height (m))^2
and rounded to two decimal places.category
should be a string indicating the BMI category: "underweight", "healthy", "overweight", or "obese".
- A tuple
BMI Range | Category |
---|---|
Less than 18.5 | Underweight |
18.5 - 24.9 | Normal weight |
25 - 29.9 | Overweight |
30 and above | Obese |
Output Formatting:
- The BMI value must be restricted to 2 decimal places.
- The category string should be in lowercase and trimmed of any extra spaces.
Examples:
-
Input:
calculate_bmi(170, 82.2)
Expected Output:(28.41, "overweight")
-
Input:
calculate_bmi(150, 77.1)
Expected Output:(34.27, "obesity")