Question: 2 9 . Implement get _ weather _ violation You now have all the tools you need to detect a weather violation. The function get
Implement getweatherviolation
You now have all the tools you need to detect a weather violation. The function getweatherviolation takes a weather report and a set of minimums visibility ceiling, wind, and crosswind and determines whether the current weather conditions violate those minimums. Obviously it will use the functions badvisibility, badwinds, and badceiling to determine this.
The result is returned as a string. A visibility violation is returned as "Visibility", a wind violation is returned as "Winds", and a ceiling violation is returned as "Ceiling". If there are multiple violations, this function should return "Weather". If there are no violations, it should return the empty string.
Implement this function as specified and run the test script. If you have done everything correctly, you should see the following:
Testing module violations
violations.badvisibility passed all tests
violations.badwind passed all tests
violations.badceiling passed all tests
violations.getweatherreport passed all tests
violations.getweatherviolation passed all tests
Again, you will notice that it will take several seconds to complete the test of getweatherreport. This is a minor inconvenience for the rest of the Python module.
def getweatherviolationweatherminimums:
Returns a string representing the type of weather violation empty string if flight is ok
The weather reading is a dictionary with the keys: 'visibility', 'wind', and sky
These correspond to a visibility, wind, and ceiling measurement, respectively. It
may have other keys as well, but these can be ignored. For example, this is a possible
weather value:
"visibility":
"prevailing":
"minimum":
"maximum":
"units": FT
"wind":
"speed":
"crosswind":
"gusts":
"units": KT
"temperature":
"value":
"units": C
sky:
"cover": "clouds",
"type": "broken",
"height":
"units": FT
"weather":
"light snow"
The minimums is a list of the four minimums ceiling, visibility, and max windspeed,
and max crosswind speed in that order. Ceiling is in feet, visibility is in statute
miles, max wind and cross wind speed are both in knots. For example,
is a potential minimums list.
This function uses badvisibility, badwinds, and badceiling as helpers. It returns
'Visibility' if the only problem is bad visibility, 'Winds' if the only problem is
wind, and 'Ceiling' if the only problem is the ceiling. If there are multiple
problems, it returns 'Weather', It returns 'Unknown' if no weather reading is
available eg weather is None Finally, it returns the empty string if
the weather is fine and there are no violations.
Parameter weather: The weather measure
Precondition: weather is dictionary containing a visibility, wind, and ceiling measurement,
or None if no weather reading is available.
Parameter minimums: The safety minimums for ceiling, visibility, wind, and crosswind
Precondition: minimums is a list of four floats
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
