Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions