QUESTION

Text
Image

# Student A wants to select gifts for student B. Student A uses two dictionaries to record two types of ratings for options s/he considers: a dictionary that records the rating of how good a gift would be for student $B$ (on a scale of 1-5), and a dictionary that records the rating of how much student $B$ wants the gift (on a scale of 1-5). The rating of a gift that is not in either of the dictionaries is considered to be 0 . Student A wants to select the gifts with the maximal possible combined rating, where the combined rating is the sum of the rating of how good the gift would be for the student and the rating of how much the student wants the gift. For example, the dictionaries can be: $\begin{array}{l} \text { good_ratings }=\{\text { "Python textbook": 5, "iPhone": 1, "iPad": 4, "AirPods": 4\} } \\ \text { want_ratings }=\{\text { "iPhone": 5, A+ in ISOM3400": 5, "Python textbook": 3, "AirPods": 4, "Xbox": 5\} } \end{array}$ Here, the gifts student A wants to select are "Python textbook" and "AirPods", since the combined rating for them is 5+3=4+4=8, larger than any other one. The combined rating of "Xbox" is $5+0=5$. Write a function with the signature select_gifts_(good_ratings, want_ratings) that returns a list of all the gifts which have the highest combined rating of all the gifts, sorted in alphabetical order. For example, for good_ratings and want_ratings as defined above, select_gifts(good_ratings, want_ratings) should return ['AirPods', 'Python textbook'].  