08 Team Activity: Dictionaries
Instructions
Work as a team as explained in the instructions for the lesson 2 team activity.
Problem Statement
The Church of Jesus Christ of Latter-day Saints uses lots of computer technology to collect and store family history data, including data about individuals and marriages. Interestingly, the data about individuals must be stored separately from the data about marriages because some individuals get married multiple times. However, in order to make the data understandable to people, when a person views marriage data, a program must combine the marriage data and the individual data.
Helpful Documentation
- The preparation content for the previous lesson explains how to retrieve an element from a list.
- The preparation content for this lesson explains how to find an item in a dictionary and how to process all the items in a dictionary.
Assignment
As a team, write a Python program that stores data about
individuals in one dictionary and stores data about marriages in a
different dictionary. Your program must combine the data in the two
dictionaries and print the combined data so that it is understandable
to a user. Start your program by downloading and saving the
family_history.py
Python file and then open it in VS Code and complete the Core
Requirements.
Core Requirements
- Within your program, the
print_death_age
function must print the name and age at death for each person in the people dictionary. - The
count_genders
function must count and print the number of males and the number of females in the people dictionary. - The
print_marriages
function must print the following for each marriage in the marriages dictionary:- The name and age in the wedding year of the husband
- The year of the wedding
- The name and age in the wedding year of the wife
Stretch Challenges
If your team finishes the core requirements in less than an hour, complete one or more of these stretch challenges. Note that the stretch challenges are optional.
- Add code to the
print_death_age
function that prints the birth year and death year for each person. - Add to your program a function named
count_marriages
that counts and prints the number of marriages that each person had in his or her lifetime. According to the data, who married the most times?
Testing Procedure
Verify that your program works correctly by following each step in this testing procedure:
- Run your
family_history.py
program and verify that it prints the same results as shown below.> python family_history.py Ages at Death Lola Park 43 Savanna Foster 49 Tiffany Hughes 58 Ignacio Torres 65 Yasmin Li 15 Trent Ross 52 Samyukta Nguyen 57 Joel Johnson 76 Whitney Nelson 66 Khalid Ali 55 Davina Patel 85 Enzo Ruiz 0 Lauren Smith 2 Lucas Ross 53 Jamal Gray 21 Fatima Soares 86 Ephraim Foster 54 Peter Price 46 Rosalina Jimenez 81 Rachel Johnson 64 Vanessa Bennet 80 Jose Castillo 47 Liam Myers 48 Isabella Lopez 52 Megan Anderson 36 Genders Number of males: 12 Number of females: 13 Marriages Ignacio Torres 18 > 1711 < Tiffany Hughes 22 Trent Ross 17 > 1722 < Savanna Foster 48 Ignacio Torres 31 > 1724 < Tiffany Hughes 35 Samyukta Nguyen 57 > 1774 < Whitney Nelson 17 Joel Johnson 51 > 1775 < Whitney Nelson 18 Joel Johnson 68 > 1792 < Davina Patel 17 Khalid Ali 45 > 1804 < Whitney Nelson 47 Khalid Ali 49 > 1808 < Davina Patel 33 Jamal Gray 20 > 1830 < Fatima Soares 18 Lucas Ross 53 > 1853 < Fatima Soares 41 Peter Price 27 > 1859 < Davina Patel 84 Ephraim Foster 44 > 1875 < Fatima Soares 63 Jose Castillo 21 > 1905 < Vanessa Bennet 25 Jose Castillo 33 > 1917 < Rachel Johnson 41 Liam Myers 23 > 1925 < Isabella Lopez 18 Jose Castillo 41 > 1925 < Rosalina Jimenez 50 Jose Castillo 44 > 1928 < Megan Anderson 19
Sample Solution
Please work diligently with your team for the one hour meeting. After the meeting is over, please compare your solution to the sample solution and the stretch solution. Please do not look at the sample solutions until you have either finished the program or diligently worked for at least one hour. At the end of the hour, if you are still struggling to complete the assignment, you may use the sample solution to help you finish.
Submission
When you have finished the activity, please report your progress via the associated I‑Learn quiz. When asked about which of the requirements you completed, feel free to include any work done during the team meeting or after the meeting, including work done with the help of the sample solution, if necessary. In short, report on what you were able to accomplish, regardless of when you completed it or if you needed help from the sample solution.