NextClass Assignment 4
The following exercises come from the end of Chapter 3 in your textbook. Please write all functions, along with their corresponding docstrings, and place them in a file named NC4.py and place it in your Assignment Inbox. Note that there is no main function required, but you must have tested the functions with at least all of your examples in the functions' docstring, and they must match exactly. That is one of the things I will be testing when I check your work.
Exercise 1
Following the function design recipe, define a function named triple that has one parameter, a number, and returns that number tripled.Exercise 2
Following the function design recipe, define a function named absdiff that has two parameters, both numbers, and returns the absolute value of the difference of the two. Hint: Call the built-in abs function.Exercise 3
Following the function design recipe, define a function named km2miles that has one parameter, a distance in kilometers, and returns the distance in miles. (There are 1.6 kilometers per mile.)Exercise 4
Following the function design recipe, define a function named average3 that has three parameters, grades between 0 and 100 inclusive, and returns the average of those grades.Exercise 5
Following the function design recipe, define a function named average3best that has four parameters, all of them grades between 0 and 100 inclusive, and returns the average of the best 3 of those grades. Hint: Call the function that you defined in the previous question.Exercise 6
Complete the examples in the docstring and then write the body of the following function:def weeks_elapsed(day1, day2): """ (int, int) -> int day1 and day2 are days in the same year. Return the number of full weeks that have elapsed between the two days. >>> weeks_elapsed(3, 20) 2 >>> weeks_elapsed(20, 3) 2 >>> weeks_elapsed(8, 5) >>> weeks_elapsed(40, 61)