Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

this is an old reference guide question found on the internet

Using the starter code that includes two functions that convert between metric and imperial values for distance (inches <-> centimeters) and weight (pounds <-> kilograms), your job is to test these functions. You should write a main() in test_measurements.py; when we run it, we should see all of your tests, the expected result for each one, and the actual result for each one.

*** Testing inches -> cm conversions

Converting 0 inches to centimeters:
>>result = 0.00 expected = 0.00

Converting 1 inches to centimeters:
>> result = 2.53 expected =2.54


*** testing cm-> inches conversions

Converting 0 centimeters to inches:
>> result = 0.00 expected = 0.00

Converting 38 centimeters to inches:
>> result = 14.96 expected = 14.96

PYTHON 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 positivedef 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 positivedef 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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education