Question: Create a new file in the Python Editor and copy-paste the following code into it: (This code is the same as the code in the

Create a new file in the Python Editor and copy-paste the following code into it: (This code is the same as the code in the "Creating a Module" section of Lecture 4) (When copying from a PDF file, indenting of code is likely to be removed - remember to add it back as needed!) Save the file as "convert.py", then create a new file and copy-paste the following code into it: (This code is the same as the code in the "Creating a Module" section of Lecture 4) Save this file (filename not important) in the same folder as convert.py, then run the code to test it. Once you've made sure that it is working, enhance convert.py to make it more useful in these ways: 1. Add a second parameter named "rounding" to each of the functions. The parameter should have a default value of 2, and should be used to round the result of the function. Test your work by calling the functions in your second file: convert.cm2inches(7) should return a value of 2.75 convert.m2yards(10, 1) should return a value of 10.9 2. Add a third parameter named "addUnit" to each of the functions. The parameter should have a default of False. If True is specified for the parameter when the function is called, the function should return a string of the result with the unit of measurement at the end, e.g. '2.75 inches' instead of 2.75. Test your work by calling the functions: convert.m2feet(5, 0, True) should return 16.0 feet convert.km2miles(2, addUnit=True) should return 1.24 miles MM_IN_INCH = 25.4 MM_IN_FOOT = 304.8 MM_IN_YARD = 914.4 MM_IN_MILE = 1609344 def cm2inches(cm): return cm * 0.393 def m2feet(m): return m * 3.281 def m2yards(m): return m * 1.094 def km2miles(km): return km * 0.621 Python import convert print('20 metres is', convert.m2feet(20), 'feet.') print('4 miles is', convert.MM_IN_MILE * 4, 'millimetres.')

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 Mathematics Questions!