Question: Python There are several weather stations positioned around a city and each station records the temperature at midday. However, one of the temperature instruments is

Python There are several weather stations positioned around a city and eachPython

There are several weather stations positioned around a city and each station records the temperature at midday. However, one of the temperature instruments is faulty and does not always produce a measurement. It is suspected that the temperature readings for this instrument may also be faulty, so we need to perform some basic analysis. The data we need is stored in a text file. Each line of the file records the temperature for a different day. The first day is considered to be day 1, and each subsequent line of the file records the following days in sequential order (e.g. the 3rd line of data is collected from the 3rd day). If there was no data collected for a given day then the entire line will be blank. For example, a valid input file might contain the contents: 23 24.5 25 22.25 22.5 23.4 25.2 20.0 This file contains data collected for 6 days. Define a function named analyse_temperatures (filename) that takes a filename as a parameter, reads the data from the parameter file and analyses the temperatures. The function should return a list of average temperatures per day. For example, the function returns the following list for the above text file: [23.75, 25.0, 22.375, 0, 23.4, 22.6] For example: Test Result [20.0, 20.5, 0, 20.0, 19.5] with open('test_temp_01.txt', 'w') as out: d = ['20 20', '20.5 20.5', '', '19.5 20.5', '19.5'] out.write(' '.join(d)) print(analyse_temperatures('test_temp_01.txt'))

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!