Explain why functions are useful.
For each of the following snippets of Python code, give what would be printed to the command line if run. If the snippet will not print anything because of an error, just put error.
print(7 // 2)
print(7 / 2)
def spam(eggs): return eggs * eggs ham = spam(spam(2)) print(ham)
def spam(eggs, ham): eggs = ham return ham eggs = 2 ham = eggs + 1 spam(eggs, ham) print(eggs)
spam = 1 for i in range(5): spam = spam / i print(spam)
for i in range(-10, 10, 3): print(i, end=' ')
Write the function average(num1, num2, num3)
that
returns the average of the three specified numbers.
Write the function sum_of_threes(num)
that returns
the sum of all positive integers that are evenly divisible by
three and less than the specified integer.