ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 27 May 2017 My Price 8.00

def median_scores(fv)

*python 3.1 ( Please provide me both the function and the main program and also the output to make sure the program does work)

 

Write and test the following function:

def median_scores(fv):
    """
    -------------------------------------------------------
    Determines the median of a series of integers in a file.
    Use: m = median_scores(fv)
    -------------------------------------------------------
    Preconditions:
        f - a file variable for a file of integers (file)
    Postconditions:
        returns
        median - the median of the values in the file (float)
    -------------------------------------------------------
    """

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. You may use Python's built-in sort method to sort the contents of the list after they have been read from the file.

 

 

Use the file numbers.txt. for testing.

numbers.txt

12
15
32
14
3
234
197
45
241
67
18
91
126
22
111
4
78
21
200
183
9
37
42

Answers

(11)
Status NEW Posted 27 May 2017 05:05 AM My Price 8.00

-----------

Not Rated(0)