Text: Python
231
209
233
204
268
-1
For your seventh and final programming assignment, you are to write a program that reads the scores of bowlers on a team from an external text file, "bowl.txt", that I have provided. The program will determine the number of bowlers on the team and calculate the average score for the team, the highest score on the team, and the lowest score on the team. These results will be displayed on the screen and also sent to an external text file, "results.txt". Please note that the text file, "bowl.txt", indicates the end of the file with a value of -1.
Make sure that your program includes a description to the reader that explains what the program does and what is produced as output and where. Also, describe the program to the user.
Your program is to be written using the following functions as follows:
1. DescribeProgram() - a void function that describes what the program does and where the results are sent.
2. ComputeStats() - a value-returning function that (1) opens communications between a file object, bowlObj, and the external text file, "bowl.txt"; (2) uses a while loop that reads line by line from the text file, "bowl.txt", to count the number of scores, count, find the average score, average, the highest score, highest, and the lowest score, lowest; (3) closes the communication between the file object, bowlObj, and the text file, "bowl.txt"; and (4) returns the number of scores, count, the average score, average, the highest score, highest, and the lowest score, lowest. Hint! The while loop uses a while score != -1: process the score. This program is very similar to the quiz.py that we did during the class session!
3. showResults(count, average, highest, lowest) - a void function that accepts count, average, highest, and lowest and sends these results to the screen. It then opens communications between a file object, outputObj, and an external text file, "results.txt", to write to, send the results also to the text file, "results.txt", and finally closes communications between the file object, outputObj, and the external text file, "results.txt".
4. main() - This function simply calls the functions that you wrote. That is,
def main(): describe_program()
count, average, highest, lowest = ComputeStats()
showResults(count, average, highest, lowest)
Don't forget to call the main() function!
Please and Thank you!