• Filename: test_measurements.py • Starter code: measurement conversions.py 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. You have flexibility with regards to your output since we won't be using the Gradescope autograder to examine your output text. However, we will be manually inspecting your output, so be sure your output is readable and clean. Here's an example of part of our test suite running (this is a small snippet, not the entire run): *** Testing inches -> cm conversions Converting 0 inches to centimeters: >> result = 0.00 expected = 0.00 Converting 1 inches to centimeters: >> result = 2.54 expected = 2.54 ..etc. *** Testing cm -> inches conversions Converting 0 centimeters to inches: expected >> result = 0.00 = 0.00 Converting 38 centimeters to inches: >> result = 14.96 expected = 14.96 ...etc. Structuring your code: • You have little-to-no repeated code, because you've so wisely put anything that gets repeated into functions. • We won't be using the auto-grader for this part of the assignment. To earn full credit for correctness, make sure your output is clean, clear and easy to read for visual verification of results

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
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))
 
 
 
 
 
 
 
value
Parameters:
centimeters (float) -- the original weight in kilograms
Returns a float value representing the original vaule converted
to pounds
'''
• Filename: test measurements.py
• Starter code: measurement_conversions.py
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.
You have flexibility with regards to your output since we won't be using the Gradescope autograder to examine your output text.
However, we will be manually inspecting your output, so be sure your output is readable and clean. Here's an example of part of our test suite
running (this is a small snippet, not the entire run):
*** Testing inches ->
cm conversions
Converting 0 inches to centimeters:
0.00 expected
>> result
= 0.00
%D
Converting 1 inches to centimeters:
2.54 еxpected
>> result
= 2.54
%3D
..etc.
*** Testing cm -> inches conversions
Converting 0 centimeters to inches:
>> result = 0.00 expected
0.00
Converting 38 centimeters to inches:
= 14.96
>> result
expected
14.96
..etc.
Structuring your code:
• You have little-to-no repeated code, because you've so wisely put anything that gets repeated into functions.
• We won't be using the auto-grader for this part of the assignment. To earn full credit for correctness, make sure your output is clean, clear
and easy to read for visual verification of results
Transcribed Image Text:• Filename: test measurements.py • Starter code: measurement_conversions.py 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. You have flexibility with regards to your output since we won't be using the Gradescope autograder to examine your output text. However, we will be manually inspecting your output, so be sure your output is readable and clean. Here's an example of part of our test suite running (this is a small snippet, not the entire run): *** Testing inches -> cm conversions Converting 0 inches to centimeters: 0.00 expected >> result = 0.00 %D Converting 1 inches to centimeters: 2.54 еxpected >> result = 2.54 %3D ..etc. *** Testing cm -> inches conversions Converting 0 centimeters to inches: >> result = 0.00 expected 0.00 Converting 38 centimeters to inches: = 14.96 >> result expected 14.96 ..etc. Structuring your code: • You have little-to-no repeated code, because you've so wisely put anything that gets repeated into functions. • We won't be using the auto-grader for this part of the assignment. To earn full credit for correctness, make sure your output is clean, clear and easy to read for visual verification of results
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar 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