Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need assistance in implementing this function correctly please. def get _ weather _ report ( takeoff , weather ) : Returns
I need assistance in implementing this function correctly please.
def getweatherreporttakeoffweather:
Returns the most recent weather report at or before takeoff.
The weather is a dictionary whose keys are ISO formatted timestamps and whose values
are weather reports. For example, here is an example of a small portion of a
weather dictionary:
T::::
"visibility":
"prevailing":
"units": SM
"wind":
"speed":
"crosswind":
"units": KT
"temperature":
"value":
"units": C
sky:
"cover": "clouds",
"type": "broken",
"height":
"units": FT
"code": Z
T::::
"visibility":
"prevailing":
"units": SM
"wind":
"speed":
"crosswind":
"units": KT
"temperature":
"value":
"units": C
sky:
"type": "overcast",
"height":
"units": FT
"code": Z
If there is a report whose timestamp matches the ISO representation of takeoff,
this function uses that report. Otherwise it searches the dictionary for the most
recent report before but not equal to takeoff. If there is no such report, it
returns None.
Example: If takeoff was as am on April Eastern this function returns
the value for key T::: If there is no additional report at
am a am takeoff would use this value as well.
Parameter takeoff: The takeoff time
Precondition: takeoff is a datetime object
Paramater weather: The weather report dictionary
Precondition: weather is a dictionary formatted as described above
# HINT: Looping through the dictionary is VERY slow because it is so large
# You should convert the takeoff time to an ISO string and search for that first.
# Only loop through the dictionary as a backup if that fails.
# Search for time in dictionary
# As fall back, find the closest time before takeoff
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started