This Python program calculates and evaluates the Body Mass Index (BMI) of a person based on their weight and height. The BMI is calculated using a mathematical formula, and the program determines if the BMI is within a healthy range, below, or above it.
-
bmi_calculator(w, h):
- Takes weight (w) in pounds and height (h) in inches as inputs.
- Returns the calculated BMI.
-
BMI():
- Prompts the user to enter their weight and height.
- Calculates the BMI using the
bmi_calculator
function. - Prints the calculated BMI, rounded to two decimal places.
- Determines if the BMI is within a healthy range, below, or above it, and prints the corresponding message.
- Functions: How to define and use functions to organize code.
- User Input: Collecting user input using the
input()
function. - Type Conversion: Converting user inputs to
float
for arithmetic operations. - Arithmetic Operations: Calculating BMI using a mathematical formula.
- Conditional Statements: Using
if-elif-else
statements to evaluate the BMI range. - String Formatting: Rounding and formatting the BMI value for output.