Programming Project 005  SOLUTION

Assignment Overview The goal of this project is to gain more practice with functions, files, exception handling, and dictionaries. Let’s tackle a political question. It is standard political dogma that Democrats “want big government” and that Republicans “create jobs.” Let’s see if data supports the dogma. The official source of employment statistics is the U.S. Bureau of Labor Statistics ( and we have collected data for private employment and government employment. Our assumption is that if a party is creating jobs, then private employment will increase, and if a party is creating bigger government, then government employment will increase. Your job is to extract that information from the files provided. Project Specification There are two employment data files provided. Both have comma-separated data. Look at the headings to understand their format. Numerical values are in thousands. • government_employment.txt • private_employment.txt There is also a comma-separated file on presidents, their years, and their political party. Since the transition from one term to another occurs partway through January, the last year listed for any president is the same as the first year of the next president. To keep things simple let’s count January entirely for the incoming president. That is, in the file the last year listed for a president will not count. For example, George W. Bush’s last year is listed as 2009 but he was president for only a few weeks that year so we will not count him as being president in 2009. Also, watch out for the “Jr.” for President Carter when you are reading the file—there is an extra comma. • presidents.txt 1. Your program will prompt for the file names. Use exceptions to check that each file was opened without an error. 2. As an academic requirement your program must define and use two functions in a meaningful way. 3. Calculate • the average monthly private employment for each political party • the average monthly government employment for each political party • the change in private employment from the first month to the last month of each president report the change as both a difference and as a percentage • the change in government employment from the first month to the last month of each president report the change as both a difference and as a percentage 4. Write a paragraph on your conclusions of the validity of the political dogma that “Democrats want big government and Republicans create jobs.” Refer to your program output as evidence for your conclusion. Put the paragraph in a separate document (either as proj05.tex or proj05.doc) and hand it in. Feel free to be creative. Deliverables and (proj05.tex or proj05.doc) – your source code solution (remember to include your section, the date, project number and comments in your program), and your paragraph. 1. Please be sure to use the specified file names, e.g. “” 2. Save a copy of your file in your CSE account disk space (H drive on CSE computers). 3. You will electronically submit a copy of the file using the “handin” program: Hints 1. A dictionary is a good candidate for storing the employment data. 2. There is a useful string formatting type that puts commas in numbers (either int or float): print(“{:,}”.format(123456}) 123,456
Powered by