Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedPython

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

Types of cultural maps ?

Answered: 1 week ago

Question

Discuss the various types of leasing.

Answered: 1 week ago

Question

Define the term "Leasing"

Answered: 1 week ago

Question

What do you mean by Dividend ?

Answered: 1 week ago