Question: Question 2 (4 points): Comparing Rainy Seasons Write a function, precipiation(d, a, b) that takes parameters: d: Dictionary mapping a season to an amount of

 Question 2 (4 points): Comparing Rainy Seasons Write a function, precipiation(d,

Question 2 (4 points): Comparing Rainy Seasons Write a function, precipiation(d, a, b) that takes parameters: d: Dictionary mapping a season to an amount of precipitation for that season. a : One season b: Another season if the rainfall in season a was greater than it was in season otherwise. If the rainfall was equal, return Your function should return True False b, and False Your function should handle the following errors the following ways If either a or b is not a valid season in the dictionary, you should return an error message (as a string) formatted exactly as: Error: Key is not in Dictionary If the values for the rainfall in each season are not valid for comparison, that is, one of them is not a number, return an error message (as a string) formatted exactly as: Error: Invalid data types in Dictionary?" You may assume that no test case will produce both types of errors (so you do not need to decide whether or not to return a Key Error or Invalid Type error when you encounter both). However, you should not make any assumptions about the seasons that exist--sometimes there may be a 'potato' season. [ ]: # Use this code cell to run your tests [ ]: # Write your answer here. precipitation (f "Spring": 813, "Summer" :337, "Fall": 581, "Winter": 468), "Spring","Summer")True t precipitation(t" Spring": 982, "Summer" :484, "Fall": 557, "Winter": 313, "winter", "spring")False t 1 brecipitation("Spring": 887, "Summer" :529, "Fall": 616, "Winter": 286)"Winter", "Potato""Error: Key is not in Dic t precipitation (t" Spring": 887, "Summer":529, "Fall": 616, "Winter": 286, "Potato": 17, "Winter", "Potato")True precipitation ( "Spring": cats Smmer": 313, "Fall": 1457, "Winter": 354), "Summer", "spring") 'Error: Invalid dat

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!