Fun with Statistics Part II
In this practice program, you will be modify the program you wrote for Practice 5 – Fun with Statistics, to append the user input to a list. When the user is done entering integers, loop through the list to find the sum, average, minimum, and maximum integers entered (and any other statistics you calculated). Look at the Python Practice page in the unit for examples of appending to a list.
Use tools we have learned so far in the course in your solution. This week we learned about using lists, indexes, append(), remove(), iterating over lists, passing lists to functions and accumulators. Those tools combined with the tools from previous Units are the tools you should use in this assignment. There will be plenty of time to practice more advanced topics in the future.
- Make a copy of practice5.py and name it practice7.py. Do not edit practice5.py – you may need to go back and start over, so always start with a copy! Watch the Getting Started with PyCharm tutorial on how to make a copy of your project.
- Start with the end – design what the user will see when they run your program. Add this sample run as comments in your code.
- Design first, then write your Python program.
Requirements:
- Have a main() function.
- Modify your program to store the user integers into a list.
- Have a function for every input, process (calculation), and output.
- Your program must use at least 1 FOR loop to iterate over the list and calculate the sum, average, minimum and maximum. Do not use the Python methods sum, min, max or ave.
- Your program should have function(s) to find the sum, average, minimum and maximum integers entered.
- Hint 1: The functions for sum, min, max and average should all be called after the WHILE loop from the Practice 5 has added all values to the list.
- Hint 2: Call the sum function in the average function when calculating the average.
- Your program must use input validation to only allow integers to be entered and ‘y’ or ‘n’ to continue entering integers.
- Declare result variables in functions. Do not return an equation. Assign the result variable(s) the equation result, the return the result variable(s).
- Include a function comment in each function with a description, parameters, and return values. Use “”” “”” to create your comment, take a look at the Lab 3 sample program for an example.
- Your functions should call the functions in valid.py to prompt for and return valid integers and floats, then validate for the amounts in the functions you create.