Mean value ========== Complete the following excercises: Exercise 1 ---------- .. interactive_code_block:: :caption: Use a for loop to calculate the mean value of a list of numbers list_of_numbers = [12, 3.4, 567, 8/9] for number in list_of_numbers: #.......... #.......... mean = #.......... print(mean) Exercise 2 ---------- .. interactive_code_block:: :caption: Use the built-in functions 'sum()' and 'len()' to calculate the mean value of a list of numbers list_of_numbers = [12, 3.4, 567, 8/9] mean = #.......... print(mean) Exercise 3 ---------- .. interactive_code_block:: :caption: Create a function which calculates the mean value of a list of numbers list_of_numbers = [12, 3.4, 567, 8/9] def mean(data): result = #.......... return result print(mean(list_of_numbers)) .. Exercise 4 ---------- .. interactive_code_block:: :caption: Use the standard library 'statistics' to alculate the mean value of a list of numbers import #.......... list_of_numbers = [12, 3.4, 567, 8/9] mean = #.......... print(mean(list_of_numbers)) .. # Version 1 sum_of_numbers = 0 number_of_numbers = 0 for i in list_of_numbers: sum_of_numbers += i number_of_numbers += 1 print(sum_of_numbers / number_of_numbers) # Version 2 print(sum(list_of_numbers) / len(list_of_numbers)) # Version 2b def average(l_o_n): return sum(l_o_n) / len(l_o_n) print(average(list_of_numbers)) # Version 3 import statistics print(statistics.mean(list_of_numbers))