Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In python write a function to calculate a person's body mass index (BMI), and a function to categorize this index: Using this for main :
In python write a function to calculate a person's body mass index (BMI), and a function to categorize this index:
Using this for main :
def main(): height = float( input("enter height in inches: ") ) weight = float( input("enter weight in pounds: ") ) bodyMassIndex = bmi(height, weight) bmiCat = category(bodyMassIndex) allCats = ['Underweight','Normal','Overweight','Obese'] if bmiCat in allCats: print("BMI is {0:.1f}: {1}".format(bodyMassIndex, bmiCat)) else: print ("Category error:",bmiCat,' must be one of ',allCats)
main()
a. bmi inches, pounds) returns the index using the formula below. b. category (index returns the string category of the index weight (kg) At left is the formula for calculating BMI, given a person's weight in kilograms and BMI height (m height in meters. o Your bmi function starts with the weight in pounds and height in inches, so you must convert to the metric units to calculate BMI. There are 2.20462262 pounds in one kilogram, and there are 39.3700787 inches in a meter. o Your category function is passed a bmi value, and it must return one of the strings in this list ['Underweight Norma Overweight obese in accordance with the following table BMI range Category string Underweight 18.5 Normal 18.5 to just less than 25 Overweight 25 to just less than 30 30 or greater Obese o Here are some sample results from our solution: bash-4.2$ python3 bmi. ...py enter height in inches 69 enter weight in pounds: 175 BMI is 25.8 Overweight -bash-4.2$ python3 bmi.py enter height in inches 64.2 enter weight in pounds: 118.5 BMI is 20.2 NormalStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started