python help plz
Exercise 5 Write a median function that has a numbers parameter. numbers is a list of numbers. This function returns the statistical median of the numbers list. The median of an odd-length list is the number in the middlemost number when the list is in sorted order. If the list has an even length, the median is the average of the two middlemost numbers when the list is in sorted order. You can use Python's builtin sort() method to sort the numbers list. Passing an empty list to median should cause it to return None. Don't forget to add an appropriate docstring. To test your function try the below assert statements (copy paste them to your code in the main function). assert median ([])== None, "Empty list test failed!" assert median ([1,2,3])==2, "Test 2 failed." assert median ([3,7,10,4,1,9,6,5,2,8])=5.5, "Test 3 failed." assert median ([3,7,10,4,1,9,6,2,8])=6, "Test 4 failed." import randon random. seed(42) testData =[3,7,10,4,1,9,6,2,8] for i in range (1600): random. shuffle(testData) assert median(testData) ==6 print("All tests succesfull!") Exercise 6 Write a closest Average function that has a numbers parameter. numbers is a list of numbers. This function returns the element closest to the average of the numbers list. You can use Python's built-in sum() methodif you wish. Passing an empty list to closest Average should cause it to return None. Don't forget to add an appropriate docstring. To test your function try the below assert statements (copy paste them to your code in the main function). assert closestAverage ([])= None, "Empty list test failed!" assert closestAverage ([1,2,3])==2, "Test 2 failed." assert closestAverage ([3,7,10,4,1,9,5,6,2,8])=5, "Test 3 failed." assert closestAverage ([3,7,10,4,1,9,6,2,8])=6, "Test 4 failed." import random random.seed(42) testData =[3,7,10,4,1,9,6,2,8] for i in range (10e0): random. shuffle(testData) assert closestAverage(testData) ==6 print("All tests succesfull!")