# Write a function that gets 5 numbers, # computes and returns the following: # 1. sum of the numbers # 2. average of the numbers def compute_basic_math(n1, n2, n3, n4, n5): sum = n1 + n2 + n3 + n4 + n5 avg = (n1 + n2 + n3 + n4 + n5) / 5 return sum, avg # Rewrite the previous function into 3 small functions # The first function (called compute_sum) # computes and return a sum of the numbers. # The second function (called compute_average) # computes and return an average of the numbers. # The third function gets 5 numbers, # calls compute_sum and compute_average functions, # and returns the following: # 1. sum of the numbers # 2. average of the numbers def compute_sum(n1, n2, n3, n4, n5): return n1 + n2 + n3 + n4 + n5 def compute_average(n1, n2, n3, n4, n5): return compute_sum(n1, n2, n3, n4, n5) / 5 def compute_basic_math2(n1, n2, n3, n4, n5): sum = compute_sum(n1, n2, n3, n4, n5) avg = compute_average(n1, n2, n3, n4, n5) return sum, avg print(compute_basic_math(5, 3, 2, 6, 2)) print(compute_basic_math2(5, 3, 2, 6, 2)) # consider # 1. where the functions are defined # 2. where the functions are called # 3. flow of the function calls