CS110 Introduction to Computing
Fall 2006
Lab Assignment#7
Problem: Write a program that queries the babyname databases for the usage/popularity of particular names. Your program should input lines from files in the following format:
rank Male_name Male_number Female_name Female_number
where,
rank -- The ranking of the names on this line
Male_name -- A male name of this rank
Male_number -- Number of males with this name
Female_name -- A female name of this rank
Female_number -- Number of females of this rank
This is the format of database files obtained from the U.S. Social Secutiry Administration of the top 1000 registered baby names. Each line begins with the rank, followed by the male name at that rank, followed by the number of males with that name, etc. Here is an example file containing data from the year 2002:
1 Jacob 30122 Emily 24262
2 Michael 28119 Madison 21546
3 Joshua 25859 Hannah 18559
4 Matthew 24831 Emma 16324
5 Ethan 21949 Alexis 15411
6 Joseph 21766 Ashley 15217
7 Andrew 21696 Abigail 15155
8 Christopher 21676 Sarah 14564
9 Daniel 21186 Samantha 14540
10 Nicholas 21148 Olivia 14481
...
996 Edgardo 158 Jazmyne 222
997 Garett 158 Libby 222
998 Gerard 158 Nyasia 222
999 Ryley 158 Kari 221
1000 Braulio 157 Keeley 221
As you can see from the above, in 2002, there were 30,122 male babies named Jacob and 24,262 babies named Emily, making them the most popular names used in that year. Similarly, going down the list, we see that there were 221 newborn females named, Kari, making it the 999th most popular name.
Provided are 15 data files (which you can download from here), names1900, names1910, ... names2000 contain 10-year data, i.e. names1900 has the top 1000 names from 1900-1909. The files names2000, names 2001, names2002, names2003 and names2004 contain data for just 1 year.
Your program should ask for a name of interest from the user as graphical text entry, and then plot the usage frequency of that particular name in a barchart for year 1900-2004. If a name can not be found in a particular file, use 0.
As in the last assignment, remember that your main program should be short and abstract. Most of the details for solving the problem should be divided up into functions. Build up your solution incrementally, add and test one function at a time. There is a detailed example on drawing a bar chart in sections 5.5 and 5.6 of your textbook, you might want to go over it again. Remember that setting a coordinate system can make your life a lot easier.
Your program should meet the following requirements:
What you will need to do:
Notes:
Add the following line to all your Python programs:
# File: <place name of your program file here> # Date: <date created> # Created by: <your name> # Assignment: <place assignment number here>