Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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, 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
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