pack isby definitionthe median there is just one small complication if we have an even number of valuesthere is no exact middle number in that casethe median is determined by averaging the two middle values so the median of and is ( )/ in pseudocode our median algorithm looks like thissort the numbers into ascending order if the size of data is oddmedian the middle value elsemedian the average of the two middle values return median this algorithm translates almost directly into python code we can take advantage of the sort method to put the list in order to test whether the size is evenwe need to see if it is divisible by two this is perfect application of the remainder operation the size is even if size = that isdividing by leaves remainder of with these insightswe are ready to write the code def median(nums)nums sort(size len(numsmidpos size / if size = median (nums[midposnums[midpos- ] elsemedian nums[midposreturn median you should study this code carefully to be sure you understand how it selects the correct median from the sorted list the middle position of the list is calculated using integer division as size / if size is then midpos is ( goes into just one timethis is the correct middle positionsince the three values in the list will have the indexes now suppose size is in this casemidpos will be and the four values will be in locations the correct median is found by averaging the values at midpos ( and midpos- ( now that we have all the basic functionsfinishing out the program is cinch def main()print("this program computes meanmedian and standard deviation "data getnumbers(xbar mean(datastd stddev(dataxbarmed median(data