Question: Language: Python Problem 4.10. Read temperatures from two files We consider data sets from the Norwegian Meteorological Institute, containing daily mean temperatures of any month

Language: Python

Language: Python Problem 4.10. Read temperatures from two files We consider data

Problem 4.10. Read temperatures from two files We consider data sets from the Norwegian Meteorological Institute, containing daily mean temperatures of any month of any year at Blindern (Oslo).[Ins19] Each file looks typically like this: Year: 1997. Month: April. Location: Blindern (Oslo) 9.0 12.3 15.8 13.4 11.0 16.2 13.3 12.9 14.0 14.1 12.0 17.3 15.5 15.4 The observations are given chronologically, and the temperatures are given in degrees Celsius. There are no empty lines in the bottom of the file. a) Write a function extract_data(filename) that reads any such file and returns a list of the temperatures from the given month. b) In the two files temp_oct_1945. dat and temp_oct_2014. dat you will find observations of daily mean temperatures in October 1945 and October 2014, respectively. Store the temperatures in two lists oct_1945 and oct_2014. Calculate the average, maximum and minimum value of the temperatures of both months, and print the results. You may use the numpy.mean(), numpy.max() and numpy.min() methods. c) Write a function write_formatting that takes at least filename, listi and list2 as parameters, and creates a new file with two nicely formatted columns containing the temperatures of the given months (you can assume that the months have equal lengths). Finally, call the function such that the file temp_formatted. txt is created, using the lists oct. 1945 and oct. 2014

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!