BMI Calculator That Returns Value and Category

Easy ⏱ 8 min 73% acceptance ★★★★☆ 4.3
Write a function bmi(weight_kg, height_m) that computes Body Mass Index as weight_kg / height_m ** 2, rounded to 1 decimal place, and returns a tuple (bmi_value, category) where category is "Underweight" if bmi < 18.5, "Normal" if 18.5 <= bmi < 25, "Overweight" if 25 <= bmi < 30, and "Obese" otherwise.

Examples

Example 1
Input
bmi(70, 1.75)
Output
(22.9, 'Normal')
Explanation

70 / 1.75**2 = 22.857..., rounds to 22.9, which falls in the Normal range.

Constraints

  • weight_kg and height_m are positive numbers.

Topics

Functionsmultiple return values

Companies

PractoCognizant

Hints

Hint 1

Compute the raw value first, round it, then classify the rounded value.

Hint 2

Use a simple if/elif/else chain on the bmi thresholds.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.