# TODO: Put appropriate comments including your name, and a description # of what the program does at the top of this file. from zellegraphics import * from string import * def get_input_file(window, entry_box, text_message): """Waits for a mouse click on the given window. Gets the input file name from the given text entry box. Displays messages using the given text message object. Returns an opened file.""" # Use a while loop and exception handling to check that # the file exists. # If file does not exist (IOError should be caught), # display appropriate message by calling a mutator method of the # textMessage object. Continue prompting the user # to enter the name of a file that exists. # When the user enters the name of a file that exists, break # out of the while loop and return the opened file. #------------------------------------------------------- # TODO: REPLACE WITH YOUR CODE #------------------------------------------------------- return in_file def find_sum_and_count_for_line(line): """Finds the sum and count of the numbers in the given line of text.""" #------------------------------------------------------- # TODO: REPLACE WITH YOUR CODE #------------------------------------------------------- def compute_mean_for_file(the_file): """Reads numbers from the given file, which must already be open for reading, and returns the mean of all the numbers found.""" # HINT: This function should call find_sum_and_count_for_line() # repeatedly. #------------------------------------------------------- # TODO: REPLACE WITH YOUR CODE #------------------------------------------------------- return mean def main(): """Creates the program GUI. Calls 'helper' methods to open a file given by the user and compute the mean of the numbers in the file. Displays the mean.""" #------------------------------------------------------- # TODO: REPLACE WITH YOUR CODE #------------------------------------------------------- # Can use a mouse click event to terminate the program # Don't forget to close the window you created and the # file that you opened. #------------------------------------------------------- if __name__ == '__main__': main()