In: Computer Science
code the following methods: one returning the average weekly hours and a method to add a weeks hours to the array of hours (this means creating a larger array).
# python 3.6 array_hours = [34, 41, 28, 36, 40, 30] # function to return average weekly hour def getAvgHour(lst): return sum(lst)/len(lst) # function to add a member to array of weekly hours def add(lst, mem): lst.append(mem) print('Average weekly hours: ', getAvgHour(array_hours)) add(array_hours, 50) print('Array of Hours: ', array_hours)
Note: Please drop a comment if want in any other language.