Answered step by step
Verified Expert Solution
Link Copied!

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:

image text in transcribed

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 Normal

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions