Question: IN PYTHON Imperial Conversion Given a measurement in one unit, return the equivalent measurement in the desired units or -1 if it is not

IN PYTHON

""" Imperial Conversion

Given a measurement in one unit, return the equivalent measurement in the desired units or -1 if it is not possible to convert given the conversion information below. The units could be given in either the abbreviated or full version (inch or in is acceptable)

1 thou (th) 1 inch (in) = 1000 thous 1 foot (ft) = 12 inches 1 yard (yd) = 3 feet 1 chain (ch) = 22 yards 1 furlong (fur) = 10 chains 1 mile (mi) = 8 furlongs league (lea) = 3 miles

If we do not have a way of converting from starting unit to the desired unit or if a constraint is violated we should return -1. You should round conversions to two decimal points.

Note: for this program, you only need to worry about at most two conversion steps So furlong to lea is valid test case because it only requires two steps: furlong -> mile -> lea, but inch to chain would not be a valid test case: inch -> foot -> yard -> chain """ def convert_measurement(number, starting_unit, desired_unit): """ I: a number, a starting measurement, a desired measurement P: convert the number in start measurement units to desired measurement units O: return the new number, or if a constraint is broken, return -1 (int, str, str) -> float """

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!