Question: Python language; Jupyter notebook Exercise 7 Write a function that computes the median value in a given list of numbers. Do NOT use a stats



Python language; Jupyter notebook
Exercise 7 Write a function that computes the median value in a given list of numbers. Do NOT use a stats library or some other 3rd party library. Your function will need to (1) make a copy of the specified list, (2) sort it, and (3) find its length. (4a) If the length is odd, then return the value in the middle slot. (4b) If the length is even, then return the average of the values in the 2 adjacent middle slots. ]: ## your function definition here ]: ## your tests here Exercise 8 The standard python ord function will provide the ordinal value of a character. In other words, if we reinterpret the binary pattern of a character as if it were an integer. 'a' in binary is 01100001 which is same pattern as the integer 97. ord('a') == 97 ord('c') == 99 This allows us to define the distance between 2 characters as the difference between their ordinal values: 'd' is 99-97 = 2 away from 'a'. And we can calculate the distance between words derived from the square root of the sum of each character distance squared. Define a function called dist that accepts 2 words as parameters, if the length of the words are not identifical, then return -1. Otherwise, convert both words to lower case; compute a list of distances between the corresponding letters. Then sum the square of distances and compute the square root of the final sum. For example: given 'cap' and 'bat'... the ordinal values would be [99, 97, 112] and [98, 97, 116] the difference is [99-98, 97-97, 112-116] or [1, 0, -4]. squaring and summing: 12 +02 +-42 = 1+0+ 16 = 17 return the square root of the sum V17 = 4.123 Test your definition on several examples at least one of which between words of differing length. 1 ## your function definition here ## your tests here Exercise 9 Define a helper filtering function to copy all the numbers with a provided interval [low, high) from a list of numbers. In other words, given a list of values and the extent boundaries -- low and high, you will create a list keeping the val items in the list where val >= low and val
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
