Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def invert_bdm(bdm): '''(dict of {str:dict of {int:list of str}}) -> dict of {str:list of [str, int]} Given bdm, a birthday month dictionary, return the equivalent

def invert_bdm(bdm):

'''(dict of {str:dict of {int:list of str}}) -> dict of {str:list of [str, int]}

Given bdm, a birthday month dictionary, return the equivalent birthday dictionary where keys are birthmonths and values are dictionaries that have keys as dates and values as list of names with people whose birthday is on that date. See section 1.2 of the related handout for more information.

>>> d = {"Jan": {1: ["Steve"], 5: ["Bob"]},

"Aug": {24: ["Sadia", "Tony"]}}

>>> d2 = invert_bdm(d)

>>> {"Steve": ["Jan", 1], "Bob": ["Jan", 5], "Tony": ["Aug", 24], "Sadia": ["Aug", 24]} '''

handout section 1.2

1.2 Question 2 Like a birthday month dictionary, a birthday dictionary also contains information about birthdays, but in a different format. The keys are peoples names and the values are 2- item lists describing those peoples birthdays. The first item in each list is the name of a month (a str) and the second is the day of that month (an int). For example, the following equivalent birthday dictionary has the same content, although in a different format, as the birthday month dictionary above.

{Ed: [May, 8], Peter: [May, 8],

Catherine: [February, 13], Katie: [May, 3]}

Complete the following function according to its docstring. Assume that each persons name in bdm is unique (i.e. not repeated in multiple months).

def invert_bdm(bdm):

(dict of {str:dict of {int:list of str}}) ->

dict of {str:list of [str, int]}

bdm is a birthday month dictionary. Return the equivalent birthday dictionary.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Discuss the problems associated with establishing corporate image.

Answered: 1 week ago