Designing and Using Functions

2. a. max(3, 4), then abs(-5), then min(4, 5).
b. max(2, 8), then min(4, 6, 8), then abs(4).
c. max(5.572, 3.258), then abs(-2), then round(5.572, 2).

4.

def absolute_difference(number1, number2):
""" (number, number) -> number

Return the absolute value of the difference between number1
and number2.

>>> absolute_difference(3, 7)
4
"""
return abs(number1 - number2)

6.

""" (number, number, number) -> number

each grade ranges from 0 to 100, inclusive.

88.33333333333333
"""

8.

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)
0
>>> weeks_elapsed(40, 61)
3
"""
return int(abs(day1 - day2) / 7)

10.

def square(num):
""" (number) -> number

Return the square of num.

>>> square(3)
9
"""
return num ** 2

...or:

def square(num):
""" (number) -> number

Return the square of num.

>>> square(3)
9
"""
return num * num