IT 116: Introduction to Scripting
Homework 11

Due Sunday, April 22nd at 11:59 PM


There is one deliverable for this assignment: It must be in an hw11 directory, which you must create inside a hw directory inside you it116 directory.

Make sure the script obeys all the rules in the Script Requirements page.

Copy the file numbs.txt, which you will find in /home/ghoffman/course_files/it116_files into your hw11 directory .


The script must define 4 functions You must not use any external Python module in the statistical calculations needed for these functions.


This functions must have the following header
This function must read in the numbers contained in a file, convert them to integers and add them to an array.
The function must return the array of integers it creates.


This functions must have the following header
    def list_mean(list):
This function must calculate the average (mean) of the integers in a list.
It must return the the rounded average.


This functions must have the following header
    def list_median(list):
This function must sort a list and return the value of the element in the middle of the list.


This functions must have the following header
    def list_range(list):
This function must return the difference between the highest and lowest number in a list.

Run code

At the bottom of the script you must have the following code
numbers = read_file_into_integer_list("numbs.txt")
print("numbers:             ", numbers)
print("list_mean(numbers):  ", list_mean(numbers))
print("numbers:             ", numbers)
print("list_median(numbers):", list_median(numbers))
print("list_range(numbers): ", list_range(numbers))


Your output should look like this
numbers:              [46, 19, 35, 43, 35, 33, 42, 6, 25, 6, 19, 17, 31, 1, 23, 14, 18, 24, 24]
list_mean(numbers):   24
numbers:              [1, 6, 6, 14, 17, 18, 19, 19, 23, 24, 24, 25, 31, 33, 35, 35, 42, 43, 46]
list_median(numbers): 24
list_range(numbers):  45
Be sure to run this script on the Unix machine so you know it works in the environment in which I will run it when I score your homework.