Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a function called happybirthday that takes as input three dictionaries, name_to_day, name_to_month, and name_to_year, and combines them into a single dictionary month_to_all that contains

Create a function called happybirthday that takes as input three dictionaries, name_to_day, name_to_month, and name_to_year, and combines them into a single dictionary month_to_all that contains the month as the key and the name, (day, year, age) as the value of the month_to_all dictionary. For this problem, you may assume that the current year is 2022 - i.e. age = 2022 - year. Specifically, your function should:

  1. Have input arguments happybirthday(name_to_day, name_to_month, name_to_year), expecting name_to_day as a dictionary mapping a name (string) to a day in the month (integer), name_to_month as a dictionary mapping a name (string) to a month (integer)and name_to_year as a dictionary mapping a name to a year(integer). You may assume all inputs to be valid.
  2. Create a new dictionary month_to_all where the keys are all the months contained in name_to_month (note: if a month does not appear in 'name_to_month', it should not be included in 'month_to_all'), and contains information in the following structure name, (day, year, age), with (day, year, age) being the tuple of values from name_to_day, and name_to_year corresponding to name. Note: the value we want in this new dictionary is a tuple, where the first element of the tuple is the name from 'name_to_month' and the second element of the tuple is a tuple of day, year, age.
  3. Return month_to_all.

For example, typing in

name_to_day={'jack':14,'helen':2,'zach':20} name_to_month={'jack':4,'helen':2,'zach':10} name_to_year={'jack':2014,'helen':2002,'zach':1969} 

should return

{'4': ('jack', (14, 2014, 8)), '2': ('helen', (2, 2002, 20)), '10': ('zach', (20, 1969, 53))}

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

1. How does Kiwi Experience maintain a continual customer focus?

Answered: 1 week ago