Question: Write a function find_median that takes a file handle as an input and find the median of a group of scores. Requirements: o Readthegroupofscoresfromafile(thatcontainsnumbersonly,eachlinehas3 numbers),

Write a function find_median that takes a file handle as an input and find the median of a

group of scores. Requirements:

o Readthegroupofscoresfromafile(thatcontainsnumbersonly,eachlinehas3 numbers), and put the scores into a list.

o Your function must sort the elements in order.

Find and return the median from the sorted list of scores. Here a median is the middle element of a sorted list if the number of elements is odd, and the average of the two middle elements if the number of elements is even.

o for a list [10,20,30,40,50], the median is 30 as it is the middle element (odd number of elements in the list)

o for a list [10,20,30,40,50,60], the median is 35 as it the average of 30 and 40 (two middle item in an even number of elements in the list)

Write a program q2.py that asks the test find_median function and write/print the results to

the output file output_q2.txt

SN/5467-231 SN5467-231 SN/5467-2231 SN/1234-978 SN/1607-123 SN/1408-456 SN5467-231 SN123-1234 SN*12345672 SN/2304-567

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!