Question: someone please help me to write only psedocode/program design for this python project? #open three files #find Government employment average per month #find Private employment

someone please help me to write only psedocode/program design for this python project?

#open three files #find Government employment average per month #find Private employment average per month #find Private Employment by president #find Government Employment by president

# return list for dem, rep and presidents def year(): presidents_list=[] D={} dem_year_list=[] rep_year_list=[] for line in fp_presidents: line_lst=line.strip().split(', ') presidents_list.append(line_lst) date=(line_lst[0]) D[date]=line_lst[1:] if len(line_lst)>3: if 'Democrat' in line_lst: for i in range(int(line_lst[2][0:4]),int(line_lst[2][5:])): dem_year_list.append(i) if 'Republican' in line_lst: for i in range(int(line_lst[2][0:4]),int(line_lst[2][5:])): rep_year_list.append(i) continue if 'Democrat' in line_lst: for i in range(int(line_lst[1][0:4]),int(line_lst[1][5:])): dem_year_list.append(i) if 'Republican' in line_lst: for i in range(int(line_lst[1][0:4]),int(line_lst[1][5:])): rep_year_list.append(i) return dem_year_list,rep_year_list,presidents_list #return avg for dem and rep, also return the list for two data files def avg(fp): D={} data_list=[] for line in fp: line_lst=line.strip().split(',') if 'Year' in line_lst: continue data_list.append(line_lst) date=int(line_lst[0]) D[date]=line_lst[1:] dem_total=0 rep_total=0 for key in D: if key in dem_year_list: for month in range(12): dem_total+=int(D[key][month]) if key in rep_year_list: for month in range(12): rep_total+=int(D[key][month]) return dem_total/(len(dem_year_list)*12),rep_total/(len(rep_year_list)*12),data_list # find the data for each presidents def difference(data_list): if data_list==private_data_list: print(' private Employment by president (millions)','{:12s}'.format(' President'),\ '{:14s}'.format('First Month'),'{:13s}'.format('Last Month'),'{:13s}'.format('Difference'),\ '{:13s}'.format('Percentage')) if data_list==government_data_list: print(' Government Employment by president (millions)','{:12s}'.format(' President'),\ '{:14s}'.format('First Month'),'{:13s}'.format('Last Month'),'{:13s}'.format('Difference'),\ '{:13s}'.format('Percentage')) for line in presidents_list: name='' reverse_line=line[0][::-1] for letter in reverse_line: if letter !=' ': name+=letter else: break name=name[::-1] if len(line)>3: for data in data_list: if line[2][0:4] in data: first_month=int(data[1]) if str(int(line[2][5:])-1) in data: last_month=int(data[-1]) difference=last_month-first_month print('{:10s}'.format(name),'{:12,d}'.format(first_month),'{:13,d}'.format(last_month),\ '{:13,d}'.format(difference),'{:13.1%}'.format(difference/first_month)) else: for data in data_list: if line[1][0:4] in data: first_month=int(data[1]) last_year=str(int(line[1][5:])-1) if last_year in data: last_month=int(data[-1]) difference=last_month-first_month print('{:10s}'.format(name),'{:12,d}'.format(first_month),'{:13,d}'.format(last_month),\ '{:13,d}'.format(difference),'{:13.1%}'.format(difference/first_month)) # open file and do error checking while True: try: fp_presidents=open(input('Please enter a file name for presidents:')) break except: print('***********incorrect file name***********') continue while True: try: fp_private=open(input('Please enter a file name for private_employment:')) break except: print('***********incorrect file name***********') continue while True: try: fp_government=open(input('Please enter a file name for government_employment:')) break except: print('***********incorrect file name***********') continue

year=year() dem_year_list=year[0] rep_year_list=year[1] presidents_list=year[2]

avg_government=avg(fp_government) avg_private=avg(fp_private) avg_dem_government=avg_government[0] avg_rep_government=avg_government[1] avg_dem_private=avg_private[0] avg_rep_private=avg_private[1] government_data_list=avg_government[2] private_data_list=avg_private[2]

print('Gvoernment employment average per month (millions)',\ ' Republican:','{:10,d}'.format(int(avg_rep_government)),' Democratic:','{:10,d}'.format(int(avg_dem_government))) print('Private employment average per month (millions)',\ ' Republican:','{:10,d}'.format(int(avg_rep_private)),' Democratic:','{:10,d}'.format(int(avg_dem_private)))

difference(private_data_list) difference(government_data_list) fp_presidents.close() fp_private.close() fp_government.close()

Project 3B | Big Government vs. Jobs

It is standard political dogma that Democrats want big government and that Republicans create jobs. Lets see if data supports the dogma.

The official source of employment statistics is the U.S. Bureau of Labor Statistics (http://www.bls.gov/data/#employment) 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.

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. The data for 2015 is incomplete.

  • government_employment.txt
  • private_employment.txt

There is also a comma-separated file on presidents, their years, and their political party.

  • presidents.txt

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 lets 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. Bushs 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 filethere is an extra comma. Finally, we will consider only the full years for each president so for Obama we will not count any data from 2015 (especially since the data for March and April is preliminary, not final data).

Academic Honesty Policy Reminder | Do your own work each submitted project will be compared against other submissions from current and previous semesters

Requirements

  • Prompt for the file names. Use exceptions to check that each file was opened without an error
  • All president data can only come from the presidents.txt file, i.e. you cannot code specifics about presidents into your program. We will test your program using a file of that format, but with different entries, for example we may test on a file that has three of the lines of that file
  • define and utilize functions in a meaningful way
  • Calculate and display in columns (see sample output below):
  • the average monthly private employment for each political party
  • the average monthly government employment for each political party
  • the private employment of the first month and last month of each president
  • 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 government employment of the first month and last month of each president
  • 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
  • You are NOT allowed to use Pandas to complete this assignment
  • Discuss your observations and conclusions of the validity of the political dogma that Democrats want big government and Republicans create jobs in your write-up. Refer to your program output as evidence for your conclusion.

Python Expectations

  • Utilize functions, files, exception handling, and dictionaries

Assumptions

  • Document any assumptions in your write-up

Write-up & Submission Requirements

Review the provided rubric and understand project expectations, including documentation, CMSC206, and programming requirements.

Two artifacts MUST BE submitted for this project Python code and a write-up.

At a minimum, the write-up needs to address -

  • Approach, design & algorithm
    • DO NOT start coding your project immediately! Come up with a high level design of the project first
      • Whats your game plan to complete the project?
      • Break the project into smallest modules where applicable
    • Complete this step first, then write your code
    • Each student is welcome to expand on the design, if it makes sense. Students will not be penalized for going above and beyond the specifications of the project
  • Test plan & test cases
    • What test cases did you run?
    • Capture test runs as screenshots in your write-up, as you run your test cases
    • I want to understanding your thinking, as to how you are testing your program
    • Each submission should be rock solid, with zero bugs
    • I am a typical user and will be able to break your code with ease
  • Any assumptions that you are making for this project
  • Highlight your learning experience and lessons learned
    • I am very interested to learn about what you have done, how you did, etc.

Not clear? Thats okay, but do ask your questions. I did not know or I did not understand is not good enough.

Start working on each project immediately so that we can discuss any concerns or questions you have!

Sample Output

Government employment average per month (millions)

Republican: 19,019

Democratic: 19,676

Private employment average per month (millions)

Republican: 94,750

Democratic: 98,416

Private Employment by president (millions)

President First Month Last Month Difference Percentage

Carter 65,636 74,570 8,934 13.6%

Reagan 74,677 89,170 14,493 19.4%

Bush 89,394 90,617 1,223 1.4%

Clinton 90,904 111,919 21,015 23.1%

Bush 111,861 112,217 356 0.3%

Obama 111,398 118,690 7,292 6.5%

Government Employment by president (millions)

President First Month Last Month Difference Percentage

Carter 15,056 16,373 1,317 8.7%

Reagan 16,360 17,736 1,376 8.4%

Bush 17,774 18,878 1,104 6.2%

Clinton 18,901 20,804 1,903 10.1%

Bush 20,835 22,556 1,721 8.3%

Obama 22,579 21,902 -677 -3.0%

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!