CSCI111 Chapter 10: Program 7 - Median

This function works with the median of a list of numbers. The median of a list is the middle observation

in the list. For example, for the list of numbers:

1, 3, 4, 7, 8, 10, 11

The median value is 7. There are three numbers above 7 and three numbers below 7.

For the list

1, 3, 4, 7, 8, 10, 11, 13

there are two middle values, 7 and 8. Then the median would be (7+8)/2 = 7.5.

So to find the median of a list we do the following.

1. Sort the list

2. Determine the number of items in the list

3. If the number in the list is odd, then the median is the middle value. If the number of numbers in

the list is even, then the median is the average of the middle two observations.

Write a function called middle(llist) that takes a list as the argument and returns the median value.

There are many ways to do this. I used a recursive function combined with the sort and pop commands,

but you may find another way.

Requirements for this program are as follows:

1. Your program must include a comment header with Author, Assignment (Program 7), Description,

and Due Date

2. Your function may not use any of Python’s pre-built median functions.

3. Your function should use list methods and operations to find the median.

4. Your program that you submit must be a script in a file named program7 WillM.py where you

replace WillM with your first name and last initial.

5. Submit just that program on Blackboard under Chapter 10, Program 7.

Need a custom answer at your budget?

This assignment has been answered 6 times in private sessions.

© 2024 Codify Tutor. All rights reserved