Speed Reading: Average numbers from an input file.
This problem requires you to combine the ideas of:
IMPORTANT: This is a more challenging problem than you have faced before. Because of that, you are allowed to work with a partner, using good pair programming techniques, and you have until session 12 to complete this problem. You will have an additional homework assigned in session 11, so you should attempt to complete this homework before your next class meeting and bring any questions to that meeting.
Your task is to read numbers from a file and calculate the mean of the numbers. Unfortunately, the file is a bit malformed. The numbers are generated by a radar gun that measures the speed of each vehicle on the road coming up the hill from the SRC. Due to an intermittent open circuit occasionally multiple numbers are written on a single line, like this:
23.2 15.6 19.8
Occasionally the radar gun also puts a
single
stray character at the end of a number, like
17.9a
instead of
17.9, or
24.9$
instead of
24.9. A sample input file is available here:
speeds.txt.
Write a program called fileAverages.py that calculates the mean of numbers in a file. Your program must conform to the following specification.
setText()
method to change the displayed value of a string that has already been drawn.
Be sure to include your name, and your partner's name if you have a partner, in a comment in your program. Submit your program by uploading your fileAverages.py file and at least three test input files that you created to the fileAverages drop box in the Homework 10 folder on ANGEL.