or this part of the assignment, you will create functions to calculate a person's body mass index (BMI). The formula you must use for this calculation is: BMI= (weight/height * height)  **************Where weight is measured in kilograms and height is measured in meters.   Do This: Write two functions: bmi() and imperial_bmi() that computes and returns the body mass index (BMI) of an individual. The first function - bmi takes the height and weight using metric measurements (centimeters and kilograms) and the second function (imperial_bmi) uses imperial measurements (inches and pounds). We will be using the auto-grader for this part of the assignment so your functions must match the specs precisely. Note: The BMI (metric) formula (given above) uses meters but our function for the bmi() takes centimeters as one of its parameters: bmi(height, weight):     '''     Function -- bmi         Takes as input height and weight in cm and kg and returns         the BMI value     Parameters:         height (in cm)         weight (in kg)     Returns a float value representing the calculated bmi     ''' imperial_bmi(height, weight):     '''     Function -- imperial_bmi         Takes as input height in inches and weight in pounds &         returns the BMI value     Parameters:         height (in inches)         weight (in pounds)     Returns a float value representing the calculated bmi     '''   Note: You do NOT need to provide a main() for this part of the assignment. You may write other "helper" functions if you wish (make sure you import any extra files you create AND include those files in your homework submission), but you must provide the bmi() and imperial_bmi() functions precisely as specified here. Note: You must use the measurement_conversion functions provided (you tested them thoroughly, right?). Hardcoding conversion values in your solution will result in marks being deducted from your grade.     STARTING CODE  INCHES_TO_CM = 2.54 POUNDS_TO_KG = 0.453592 def inches_to_cm( inches ):    '''    Function -- inches_to_cm        Converts inches to centimeters and returns (answers) the resulting        value    Parameters:        inches (float) -- the original distance/height in inches    Returns a float value representing the original vaule converted        to centimeters    '''    return abs(inches * INCHES_TO_CM) # convert negative distance to positive def cm_to_inches( centimeters ):    '''    Function -- cm_to_inches        Converts centimeters to inches and returns (answers) the resulting        value    Parameters:        centimeters (float) -- the original distance/height in centimeters    Returns a float value representing the original vaule converted        to inches    '''    return abs(centimeters * (1 / INCHES_TO_CM)) def pounds_to_kg( pounds ):    '''    Function -- pounds_to_kg        Converts pounds to kilograms and returns (answers) the resulting        value    Parameters:        pounds (float) -- the original weight in pounds    Returns a float value representing the original vaule converted        to kilograms    '''    return abs(pounds * POUNDS_TO_KG) # convert negative weight to positive def kg_to_pounds( kg ):    '''    Function -- cm_to_inches        Converts kilograms to pounds and returns (answers) the resulting        value    Parameters:        centimeters (float) -- the original weight in kilograms    Returns a float value representing the original vaule converted        to pounds    '''    return abs(kg * (1 / POUNDS_TO_KG))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this part of the assignment, you will create functions to calculate a person's body mass index (BMI).
The formula you must use for this calculation is:

BMI= (weight/height * height) 

**************Where weight is measured in kilograms and height is measured in meters.

 

Do This: Write two functions: bmi() and imperial_bmi() that computes and returns the body mass index (BMI) of an individual. The first function - bmi takes the height and weight using metric measurements (centimeters and kilograms) and the second function (imperial_bmi) uses imperial measurements (inches and pounds).

We will be using the auto-grader for this part of the assignment so your functions must match the specs precisely.
Note: The BMI (metric) formula (given above) uses meters but our function for the bmi() takes centimeters as one of its parameters:

bmi(height, weight):

    '''

    Function -- bmi

        Takes as input height and weight in cm and kg and returns

        the BMI value

    Parameters:

        height (in cm)

        weight (in kg)

    Returns a float value representing the calculated bmi

    '''

imperial_bmi(height, weight):

    '''

    Function -- imperial_bmi

        Takes as input height in inches and weight in pounds &

        returns the BMI value

    Parameters:

        height (in inches)

        weight (in pounds)

    Returns a float value representing the calculated bmi

    '''

 

Note: You do NOT need to provide a main() for this part of the assignment. You may write other "helper" functions if you wish (make sure you import any extra files you create AND include those files in your homework submission), but you must provide the bmi() and imperial_bmi() functions precisely as specified here.

Note: You must use the measurement_conversion functions provided (you tested them thoroughly, right?). Hardcoding conversion values in your solution will result in marks being deducted from your grade.

 

 

STARTING CODE 


INCHES_TO_CM = 2.54
POUNDS_TO_KG = 0.453592


def inches_to_cm( inches ):
   '''
   Function -- inches_to_cm
       Converts inches to centimeters and returns (answers) the resulting
       value
   Parameters:
       inches (float) -- the original distance/height in inches
   Returns a float value representing the original vaule converted
       to centimeters
   '''

   return abs(inches * INCHES_TO_CM) # convert negative distance to positive

def cm_to_inches( centimeters ):
   '''
   Function -- cm_to_inches
       Converts centimeters to inches and returns (answers) the resulting
       value
   Parameters:
       centimeters (float) -- the original distance/height in centimeters
   Returns a float value representing the original vaule converted
       to inches
   '''

   return abs(centimeters * (1 / INCHES_TO_CM))

def pounds_to_kg( pounds ):
   '''
   Function -- pounds_to_kg
       Converts pounds to kilograms and returns (answers) the resulting
       value
   Parameters:
       pounds (float) -- the original weight in pounds
   Returns a float value representing the original vaule converted
       to kilograms
   '''

   return abs(pounds * POUNDS_TO_KG) # convert negative weight to positive

def kg_to_pounds( kg ):
   '''
   Function -- cm_to_inches
       Converts kilograms to pounds and returns (answers) the resulting
       value
   Parameters:
       centimeters (float) -- the original weight in kilograms
   Returns a float value representing the original vaule converted
       to pounds
   '''

   return abs(kg * (1 / POUNDS_TO_KG))

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education