Question: In a file called convert_metric.py, write a Python function called metric_conversion that will convert metric measurements to/from imperial units as follows: pounds to/from kilos

In a file called convert_metric.py, write a Python function called metric_conversion that will convert metric measurements to/from imperial units as follows: pounds to/from kilos ounces to/from grams miles to/from kilometers inches to/from centimeters Your function should do the following: take in two values: a floating point measurement and a separate "units" string from the following set: {'pounds', 'ounces', 'miles', 'inches', 'kilos', 'grams', 'kilometers', 'centimeters'} then convert the value to the corresponding units and output both the converted value and its units. Use the built-in format() function to print out 4 digits to the right of the decimal point. (i.e. 5.1234) If the "units" string is not recognized (not in those specified), your program should produce an error message and terminate the program from there. Example: Enter value: 1.0 Enter units: centimeters 0.3937 inches Enter value: 10 Enter units: ounces 283.4952 grams Enter value: Enter units: 100 grams 100 grams is not a valid unit.
Step by Step Solution
There are 3 Steps involved in it
Here is the code for the convertmetricpy file implementing the metricconversion function python def ... View full answer
Get step-by-step solutions from verified subject matter experts
