small medium large xlarge

# 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.

 Parameter num Argument 3 Function name square Function call square(3)

10.

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)
Page History
• V16: Jennifer Campbell [over 4 years ago]
• V15: Jennifer Campbell [over 4 years ago]
• V14: Jennifer Campbell [over 4 years ago]
• V13: Jennifer Campbell [over 4 years ago]
• V12: Jennifer Campbell [over 4 years ago]
• V11: Jennifer Campbell [over 4 years ago]
• V10: Jennifer Campbell [over 4 years ago]
• V9: Jennifer Campbell [over 4 years ago]
• V8: Jennifer Campbell [over 4 years ago]
• V7: Jennifer Campbell [over 4 years ago]