CMSC 201

Homework 6 - Due 3/31

This homework must be submitted by 8pm on the due date to get any credit.

You will be writing a homework using functions to get a list of integers from a user and then find statistics of the given list of integers. You are not allowed to use any built in functions for finding the calculations in this assignment.

The functions required for this assignment will be:

  1. printMenu()-Prints a menu of options to the screen
  2. getList()-Gets list of integers from user using a while loop and returns the list
  3. getMean(userList)-Returns the average of the integers contained in the list given by the user
  4. getMedian(userList)-Returns the median of the integers contained in the list given by the user
  5. printGraph(userList)-Prints a horizontal histogram of the elements in the list
  6. getMin(userList)-Finds the lowest value in the set using a for loop and then prints value to screen
  7. getMax(userList)-Returns the highest value in the set using a for loop

Example output:

Welcome to the List Statistics Calculator
To begin, enter a list of integers or  to end the list!
Enter an integer: 67
Enter an integer: 100
Enter an integer: 50
Enter an integer: 100
Enter an integer: 50
Enter an integer: 50
Enter an integer: 60
Enter an integer: q
Please choose the statistic that you would like to calculate!
1. Mean
2. Median
3. Min
4. Max
5. Graph
Please enter your choice, or 0 to exit: 1
The mean of this data set is 68.142
 Please choose the statistic that you would like to calculate!
1. Mean
2. Median
3. Min
4. Max
5. Graph
Please enter your choice, or 0 to exit: 2
The median of this data set is 60
Please choose the statistic that you would like to calculate!
1. Mean
2. Median
3. Min
4. Max
5. Graph
Please enter your choice  to exit:3
The max of this data set is 100
Please choose the statistic that you would like to calculate!
1. Mean
2. Median
3. Min
4. Max
5. Graph
Please enter your choice, or 0 to exit: 4
The min of this data set is 50
Please choose the statistic that you would like to calculate!
1. Mean
2. Median
3. Min
4. Max
5. Graph
Please enter your choice  to exit: 5
 50: X X X
 60: X
 67: X
100: X X
Please enter your choice  to exit: 0
Goodbye!

When you've finished your homework, use the submit command to submit the file. You must be logged into your account and you must be in the same directory as the file you're trying to submit. At the Linux prompt, type

submit cs201 HW6 hw6.py

After entering the submit command shown above, you should get a confirmation that submit worked correctly:

Submitting hw6.py...OK

If not, check your spelling and that you have included each of the required parts and try again.

You can check your submission by entering:

submitls cs201 HW6

You should see the name of the file that you just submitted, in this case hw6.py