Question: 9 . Implement reports _ above _ temp Read the specification of the function reports _ above _ temp in the module funcs. This function

9. Implement reports_above_temp
Read the specification of the function reports_above_temp in the module funcs. This function does not need to read the file weather.json. All of the necessary information is passed to the parameter weather.
Implement this function according to its specification. While this is a complicated dictionary, the function follows a straightforward accumulator pattern. However, there are two challenges you should be aware of all. First of all, not every weather report contains a temperature measurement. In addition, some measurements are in Fahrenheit and others are Celsius. That is why we have provided the function to_celsius as a helper.
def reports_above_temp(weather,temp):
"""
Returns the number of weather reports where temperature is above temp (in Celsius)
The parameter weather contains a weather report dictionary. This function loops
through the weather reports and counts all reports for which
(1) the report has a temperature measurement (not all reports do)
(2) the measured temperature is properly above temp in Celsius
A temperature measurement is itself a dictionary with two keys: 'value' and 'units'.
For example:
"temperature": {
"value": 57.0,
"units": "F"
}
The units are always either 'F' for fahrenheit or 'C' for celsius. If the
measurement is in fahrenheit, the value will need to be converted before it
can be compared to temp.
Parameter weather: the weather dictionary
Precondition: weather has the format described in the module introduction
Parameter temp: the temperature in celsius
Precondition: temp is a float
"""
pass

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!