Question
I need to write a Python (3.7.2) program that will do the following: 1) Ask the user to input a value 2) The user will
I need to write a Python (3.7.2) program that will do the following:
1) Ask the user to input a value
2) The user will then press the space bar once
3) The user will then enter the unit for their entered value
The units that will be used in this program are: Time, Length, Mass, Capacity, Temperature, Force, Pressure, Angles, Energy, Power
Each unit should have all the standard subunits of measurement (Mass: gram, ounce, pound, kg, stone, etc)(Length: mm, cm, meter, km, mile, feet, inch, yard, etc).
4) Input units that are multiplied are separated by a space. All units following a / sign are in the denominator. For example:
in lbf/sec = inch*pounds force/second. By comparing the part of the string after the space, the script should determine the domain.The user does not have to enter the domain explicitly.
5) The output should be 6 significant figures (5 digits to the right of the decimal point).
6) The output cannot include the unit the user originally entered (if user entered 5 kg, the output should be conversions of the other mass units except for kg).
7) The code should be written so that adding new units to domains and adding new domains requires changing only a few lines of code without adding whole new variables. For instance, adding a new domain should not require a new variable to be declared, just that a previously defined list or dictionary be expanded. Similarly, the help output that tells the users what units and domains are available should be generated automatically from the data lines. This can easily be accomplished by using dictionaries to hold the domains and unit strings.
Name the script that does this UnitConversion.py
BELOW IS AN EXAMPLE OF WHAT THE OUTPUT SHOULD LOOK LIKE:
>> Unit Converter: At any prompt, enter H for help, Q to quit.> Unit Converter: At any prompt, enter H for help, Q to quit.Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started