Please answer it in Python In order not to forget to wish the birthday of his loved ones, Alzheimer wants to memorize and manage their dates of birth via a computer program in Python. At first, it is assumed that Al has already computerized the birthday dates of his relatives in a dictionary. The keys in this dictionary are the first names of his relatives (it is assumed that no two people with the same first name). The value associated with each key corresponds to the birthday of the corresponding person, in the form of a 3-item list, containing in the order the day, month and year of birth. The day is considered to be an integer between 1 and 31, the month an integer between 1 and 12 and the year of birth an integer between 1900 and 2021. Thus the list [17, 5, 2021] corresponds to the date of May 17, 2021. This may lead to writing dates that do not exist (e.g. [31, 4, 2003]) but this is not addressed in the exercise. Here is an example of a dictionary containing the dates of birth of 5 friends of Al in this format: ddates={'Chiara': [11, 10, 1998], 'Omar': [22, 11, 2001], 'Ingrid': [12, 6, 2002], 'Marc': [27, 8, 1983], 'Youri': [12, 6, 1983]}. Al would like to be able to add new friends to the dictionary of dates of birth. Write a function add_friend that takes the ddates dictionary as an argument and asks the user for information to add a new friend. To do this, we first ask for the first name of the friend to add. If the first name entered already exists in dates, we ask again until we have a first name that is not in dates. We ask then in the agenda, the month and year of birth of the friend to be added.. We will respect the model of the example below: For example: add_friend(ddates) Friend's name: * user types Chiara * This name is already present, start again: * the user types Alicia * Enter day: * user type 40 * Error: the value must be between 1 and 31 Repeat: * user type 13 * Enter month: * user type -5 * Error: the value must be between 1 and 12 Repeat: * user type 5 * Enter year: * user type 1 * Error: The value must be between 1900 and 2021 Repeat: * user type 2001 * #Return => {'Chiara': [11, 10, 1998], 'Omar': [22, 11, 2001], 'Ingrid': [12, 6, 2002], 'Marc': [27, 8, 1983], 'Youri': [12, 6, 1983],’Alicia’: [13, 5, 2001]}.
Please answer it in Python
In order not to forget to wish the birthday of his loved ones, Alzheimer wants to memorize and manage their dates of birth via a computer program in Python. At first, it is assumed that Al has already computerized the birthday dates of his relatives in a dictionary. The keys in this dictionary are the first names of his relatives (it is assumed that no two people with the same first name). The value associated with each key corresponds to the birthday of the corresponding person, in the form of a 3-item list, containing in the order the day, month and year of birth. The day is considered to be an integer between 1 and 31, the month an integer between 1 and 12 and the year of birth an integer between 1900 and 2021. Thus the list [17, 5, 2021] corresponds to the date of May 17, 2021. This may lead to writing dates that do not exist (e.g. [31, 4, 2003]) but this is not addressed in the exercise. Here is an example of a dictionary containing the dates of birth of 5 friends of Al in this format:
ddates={'Chiara': [11, 10, 1998], 'Omar': [22, 11, 2001], 'Ingrid': [12, 6, 2002], 'Marc': [27, 8, 1983], 'Youri': [12, 6, 1983]}.
Al would like to be able to add new friends to the dictionary of dates of birth. Write a function add_friend that takes the ddates dictionary as an argument and asks the user for information to add a new friend. To do this, we first ask for the first name of the friend to add. If the first name entered already exists in dates, we ask again until we have a first name that is not in dates. We ask then in the agenda, the month and year of birth of the friend to be added.. We will respect the model of the example below:
For example:
add_friend(ddates)
Friend's name: * user types Chiara *
This name is already present, start again: * the user types Alicia *
Enter day: * user type 40 *
Error: the value must be between 1 and 31
Repeat: * user type 13 *
Enter month: * user type -5 *
Error: the value must be between 1 and 12
Repeat: * user type 5 *
Enter year: * user type 1 *
Error: The value must be between 1900 and 2021
Repeat: * user type 2001 *
#Return =>
{'Chiara': [11, 10, 1998], 'Omar': [22, 11, 2001], 'Ingrid': [12, 6, 2002], 'Marc': [27, 8, 1983], 'Youri': [12, 6, 1983],’Alicia’: [13, 5, 2001]}.
Step by step
Solved in 4 steps with 3 images