Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve in python Problem 2 Create a function called happybirthday that takes as input three dictionaries, name_to_day, name_to_month, a and name_to_year, and combines them

Please solve in python

image text in transcribed

image text in transcribed

Problem 2 Create a function called happybirthday that takes as input three dictionaries, name_to_day, name_to_month, a 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))} Note that the integer values for each month are not in ascending order: dictionaries are unordered data structures, and do not have a set 'order' for keys. Your output may be in a different order than the examples provided, and that is ok. also, name_to_day={'Stive': 24, 'Bill':28, 'Elon':28, 'Jeff':12, 'Mark':14} name_to_month={'Stive':2, 'Bill':11, 'Elon':6,'Jeff":1, 'Mark':5} name_to_year={'Stive': 1955, 'Bill':1955, 'Elon': 1971, 'Jeff': 1964, 'Mark': 1984} should output {'2': ('Stive', (24, 1955, 67)), '11': ('Bill', (28, 1955, 67)), '6': (Elon, (28, 1971, 51)), '1': ('Jeff', ( 1 2 3 def histogram(data, n, b, h): # data is a list # n is an integer # b and h are floats m 4 5 6 # Write your code here 7 8 9 10 11 # return the variable storing the histogram # output should be a list pass 12 13 14 def happybirthday (name_to_day, name_to_month, name_to_year): #name_to_day, name_to_month and name_to_year are dictionaries 15 16 # Write your code here 17 18 19 # return the variable storing name_to_all # Output should be a dictionary 20 21 22 pass

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions