Mcs260, Fall 2011, Lowman, Week5 Lab ======================================= Assume data from a temperature measuring experiment is saved in a file named temps.txt. The file is created as follows: 1. The first few rows contain comments about the file. In these lines the first non-whitespace character is "#". When processing the data, the comment rows must be ignored. 2. Each data row contans two values: temperature in Celcius and frequency. For example, a few data rows might look like: #-------------------------------------------------------- # each row contains temps in celcius and freq # Temps are of rocks found in varius places. # collected 2009 by R. J. Scientist -10.6 3 22.9 1 1.6 2 ... #-------------------------------------------------------- There may be rows of white space at the end. The row " -10.6 3" means the temperature value -10.6 occurs 3 times. You will have to create your own data file to test your code. 3. Create a directory for the program and cd into it. Create a README file as usual. In addition create two files named main.py and funcs.py 4. In the module main.py define a function named main() that will open the data file for reading and open a file named datasum.txt for writing. Import the file funcs.py where all functions except main() will be defined. (a) The main() function should pass the reference to the input file to a function that will create a new list with all of the data values. Insert a value in the list the same number of times as it occurs in the data file. For example data = [..., 1.6, 1.6, ...] if the frequency for 1.6 is 2. Return the list to the main() function. (b) from main() pass the list of data to a function that will return the maximum and minimum temperatures. (c) from main() pass the data list to a function that returns the median of the data. If you first sort the list with data.sort() then the median is the middle value if len(data) is odd and the median is the average of the middle two values if len(data) is even. (d) from main() pass the data-list and the mean to a function that will return the standard deviation of the data: V = sum-of-all [ (xi - xavg)^2 / (n-1) ]. i.e. calculate (xi - xavg)^2 / (n-1) for each data value and then find the sum. This gives V called the sample variance. The sample standard deviation s = sqrt(V). Return s. (e) Finally pass the: outfile-reference,min,max,median,std_dev to a function that will write a summary of the date to the output file. You should also write a heading to the file that identifies you,course,date,etc. (f) in the function main() close all open files. 5. Your TA will give instructions for submitting your lab work. Note, you must include comments at the top of each file giving: filename, your name at minimum. In addition, you must include doc strings for each module and function.