Back

Code Challenge: BMI Calculator

Difficulty  

divider

Objective

Calculate a Body Mass Index from a weight in pounds and a height in inches, then report which category it falls into.

BMI is a crude measure and a poor one for judging any individual person — but it makes a good code challenge.

Skills to Practice

  • Prompting a user for input
  • Using exponents
  • Rounding a result
  • Branching with if / elif / else

Tasks

  • Create a new Python program named cc-bmi-calculator.
  • Prompt for a weight in pounds and a height in inches.
  • Calculate BMI. Formula: BMI = (weight ÷ height2) × 703
  • Round the BMI to two decimal places.
  • Display the BMI and its category from the table below.
BMICategory
Below 18.5Underweight
18.5 up to 24.9Normal weight
25 up to 29.9Overweight
30 and aboveObesity

Sample Output

Sample Output
Enter your weight in pounds: 180 [Enter]
Enter your height in inches: 70 [Enter]
Your BMI is 25.82, which is considered Overweight.

Commence Challenge