Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task ( Python ) : Implement the function: convert _ units ( celsius _ value, units ) that accepts two arguments, a float ( celsius

Task (Python): Implement the function:
convert_units(celsius_value, units)
that accepts two arguments, a float (celsius_value) and an int (units).
The function will return the supplied temperature, converted as specified to a float:
- If units =0, return temperature in Celsius (no change)
- if units =1, return temperature in Fahrenheit
- if units =2, return temperature in Kelvin
Prompt the user for the Celsius temperature and units in main(), the unit-test code. Validate units in convert_units, if the user enters an invalid units value (something other than 0,1,or 2 convert_units must return an error code (I recommend that you return None) to main() and main() will tell the user and then end the program. None is a object type in Python that has only one value, None. In the real world, you would also want to check for valid values for celsius_value. Don't worry about prompting the user to reenter the units, just tell them to run the program again. When we learn about loops, we will prompt again when invalid input is presented.
Note that convert_units() must return a float (floating point number), or an error code. This float is the result of the conversion done by the convert_units() function. Your convert_units() function performs the computation based on the arguments passed and the main() function will handle all of the input/output. Remember the main() function contains the unit-test code. Code to add to: def print_header():
print("STEM Center Temperature Project")
print("Name")
def main():
print_header()
if __name__=="__main__":
main()

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 Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Describe ERP and how it can create efficiency within a business

Answered: 1 week ago

Question

Learn about the labor context in Canada and Quebec.

Answered: 1 week ago