Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this Python coding problem! If you could use #comments to describe what you are doing inside your code that would be

Please help me with this Python coding problem! If you could use #comments to describe what you are doing inside your code that would be very helpful as it will allow me to learn from what you are writing!

image text in transcribed

This is the second page of the problem below:

image text in transcribed

1. Write a semi-smart unit converter Conversion of various quantities between unit systems is a very common engineering task. The Python project for this term is to write a simple script that will do unit conversion for the user. Name the script that does this UnitConversion. py Domains The converter will work to convert units within specific domains. The domains will should include time . ength e mass capacity temperature force . pressure angles energy/moment power It is suggested, for the initial approach, that students figure out how to do two or three of the domains listed. After that is working, add the others Within each domain, there should be at least four different units supported. In addition, pick any four domains and support six types of units for that domain. The exception is angles, which need only support degrees and radians Where applicable, roughly half of the units for a domain should be metric units (m, N, liters, etc.) and the other half should be U.S. Customary units (e.g. ft, lbf, gallons, etc.). Angles and time need not meet this requirement Googling "common units for x" where x is a domain will yield handy units for each domain. Similarly, web searches will give conversion factors to high accuracy User Input The script should ask the user for a value and its units. The script will determine from those units which domain is involved and then present the user with a list of values in all of the units in that domain . The user will enter the number and then a space and then the units, all as one string . The script should recognize common short abbreviations for units. E.g. W-Watts, lbf pounds force, etc. 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 . . Output The script output should have the following features: The output values should have at least as many significant figures as the input value, with a minimum of 3 significant figures. Assume that the user may enter numbers with up to 20 significant figures. Doing this may require some thinking and it is suggested to leave this part of the script until after more basic things are working well. The output should not repeat the user's input units . The output format should print in a neat format, with the start of the output units string aligned for each output quantity. See the example output below for guidance. The user will be given the option to continue after each unit conversion is complete. If the user enters anything other than 'Q or 'q', the script should continue. . Calculations Conversion factors should have at least 6 significant figures Note that most units can be converted using a single factor in unitz const x uniti fashion. E.g. 1 meter = 39.3701 inches. But, some, like temperature follow a unit2-const unit! + const pattern and will require two constants. A clever programmer can use the same system for both types, by allowing const2 to be 0 for the domains that don't need it. The project script is to be written using no scientific or mathematical modules that the student has not written independently. The project scope is well within the programming ability of ME 021 students. Hint on setting up the math: Rather than work out all of the combinations of unit conversions within a domain (which will be quite a few for domains with 6 units), it may be useful to pick one unit as the "standard" for each domain (it won't matter which one is chosen) and then determine how to go from any unit to that standard unit and then go from that standard unit to the others Examples: (More to follow...) Enter a quantity with units: 56.371 BTU/hr Your power value of 56.371 BTU/hr converts to 0.016521 kW 16.521 W 0.022155 hp 12.185 ft lbf/sec Do another conversion or quit (Q) ? 1. Write a semi-smart unit converter Conversion of various quantities between unit systems is a very common engineering task. The Python project for this term is to write a simple script that will do unit conversion for the user. Name the script that does this UnitConversion. py Domains The converter will work to convert units within specific domains. The domains will should include time . ength e mass capacity temperature force . pressure angles energy/moment power It is suggested, for the initial approach, that students figure out how to do two or three of the domains listed. After that is working, add the others Within each domain, there should be at least four different units supported. In addition, pick any four domains and support six types of units for that domain. The exception is angles, which need only support degrees and radians Where applicable, roughly half of the units for a domain should be metric units (m, N, liters, etc.) and the other half should be U.S. Customary units (e.g. ft, lbf, gallons, etc.). Angles and time need not meet this requirement Googling "common units for x" where x is a domain will yield handy units for each domain. Similarly, web searches will give conversion factors to high accuracy User Input The script should ask the user for a value and its units. The script will determine from those units which domain is involved and then present the user with a list of values in all of the units in that domain . The user will enter the number and then a space and then the units, all as one string . The script should recognize common short abbreviations for units. E.g. W-Watts, lbf pounds force, etc. 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 . . Output The script output should have the following features: The output values should have at least as many significant figures as the input value, with a minimum of 3 significant figures. Assume that the user may enter numbers with up to 20 significant figures. Doing this may require some thinking and it is suggested to leave this part of the script until after more basic things are working well. The output should not repeat the user's input units . The output format should print in a neat format, with the start of the output units string aligned for each output quantity. See the example output below for guidance. The user will be given the option to continue after each unit conversion is complete. If the user enters anything other than 'Q or 'q', the script should continue. . Calculations Conversion factors should have at least 6 significant figures Note that most units can be converted using a single factor in unitz const x uniti fashion. E.g. 1 meter = 39.3701 inches. But, some, like temperature follow a unit2-const unit! + const pattern and will require two constants. A clever programmer can use the same system for both types, by allowing const2 to be 0 for the domains that don't need it. The project script is to be written using no scientific or mathematical modules that the student has not written independently. The project scope is well within the programming ability of ME 021 students. Hint on setting up the math: Rather than work out all of the combinations of unit conversions within a domain (which will be quite a few for domains with 6 units), it may be useful to pick one unit as the "standard" for each domain (it won't matter which one is chosen) and then determine how to go from any unit to that standard unit and then go from that standard unit to the others Examples: (More to follow...) Enter a quantity with units: 56.371 BTU/hr Your power value of 56.371 BTU/hr converts to 0.016521 kW 16.521 W 0.022155 hp 12.185 ft lbf/sec Do another conversion or quit (Q)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

2. Outline the functions of nonverbal communication

Answered: 1 week ago