[SOLVED] 代写 R data structure python database graph statistic CSE 231

30 $

File Name: 代写_R_data_structure_python_database_graph_statistic_CSE_231.zip
File Size: 593.46 KB

SKU: 7613762592 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


CSE 231
Spring 2019
Programming Project 05
Edit: 21119 Restrictions changed to allow lists. Highlighted in red.
This assignment is worth 45 points 4.5 of the course grade and must be completed and
turned in before 11:59 PM on Monday, February 18, 2019. Assignment Overview
1. Functions
2. File input and output
3. tryexcept
The goal of this project is to analyze US House of Representatives data for members seated in 2019. Use of advanced data structures such as sets, and dictionaries are prohibited. This project is designed to not use lists, but they are allowed.
Assignment Background
The 2018 midterm election was notable for the number of women elected to the House of Representatives, and the fact that many of those women were Democrats. On Reddit someone, posted a funny plot showing that there are almost as many house members named Mike as there are female Republican representatives1. An important question, especially with respect to items posted on the internet is: is the data correct? In this assignment we have gone to the source of the data to reproduce the plot. We can find data on the government website https:www.house.govrepresentatives including names, photos, states, districts, party, etc. In this project, however, we focus on their gender distribution in each party. Unfortunately, there is no prepared gender information on this website so we used a Python library named genderguesser https:pypi.orgprojectgenderguesserto generate their genders to be one of the following:
Male
Female
Almost male higher probability to be a male name
Almost female higher probability to be a female name
Unknown the name wasnt found in the database
After this preprocessing, we revised the data to make sure there are no ambiguous entries. We provide the resulting data file congress.txt, that is, we did that preprocessing work for you. Each line of congress.txt contains information of one representative, where name has at most
1 The number of House Republicans named Mike was reduced by one when the incumbent representative for the district that MSU lies in was defeated.
1

CSE 231 Spring 2019
30 characters, party at most 9 characters and gender at most 6 characters. We use R and D to denote two different parties Republican and Democrat.
Your task is to read this data file, count the number of male and female in each party and the number of guys named Mike or Michael. We also provide a completed function which you can use to plot a bar graph related to these statistical data.
Project Description
Although there are many different ways to complete the mission, your program must meet the following specifications to get the credit:
You have to use the seven functions in the provided proj05.py skeleton.
1 openfile:
This function takes no parameters, then uses the tryexcept format to prompt for a filename, open the data file and return the file pointer if successful. Your function should be able to catch the error and print the error message if it fails to open; and then reprompt. It will reprompt until successful.
2 getgenderdataline:
This function takes a string dataline as a parameter. The dataline parameter is one line from the data file. It returns the appropriate string male or female. Hint: use string slicing to extract the gender. Remember to strip off the carriage return. Remember that names are at most 30 characters, party at most 9 characters and gender at most 6 characters.
3 isMikedataline:
This function takes a string dataline as a parameter. The dataline parameter is one line from the data file. It returns True for Mike or Michael, and False for others. Hint: use the string in operator.
4 getpartydataline:
This function takes a string dataline as a parameter. The dataline parameter is one line from the data file. It returns the appropriate string Republican or Democrat.
5 printresultmaler, femaler, maled, femaled, mike:
This function takes five integers as parameters, and prints the result in following format:
PartyRepublicanDemocratic
2

CSE 231
Spring 2019
Malexxxxxxxx Femalexxxxxxxx
Dudes named Mike:xxxx
Note: For party data the leftmost column has a field width of 10 and left justified. The next two columns have a field width of 14 and right justified the squares
are an attempt to represent spaces in your output. There should be a blank line between the party data and the Mike data. The Mike data is simply the string Dudes named Mike: followed by one space followed by the count.
6 plotdatamaler, femaler, maled, femaled, mike:
This function has been completed. You should pass the same data for printresult and it will print a bar graph for you. Have fun with it.
7 main:
In the main function, use the five functions above to complete the mission! At program start call the openfile function. Read the data file line by line and use above functions to process the data, count numbers of male, female, and Mikes. Print the result. Finally, prompt to ask for a graph, and if yes, display the bar graph. Capitalization does not matter yes, Yes, yEs, etc
Assignment Deliverable
The deliverable for this assignment is the following file: proj05.pythe source code for your Python program
Be sure to use the specified file name and to submit it for grading via the Mimir before the project deadline.
Assignment Notes
Please be careful with the names in data, instead of trying to separate first name from the string, I recommend using the string in operator or searching for a substring with Mike or Michael in it. The format of the name can be very complicated with Jr., middle names or other special characters. Also, a female name Michelle is very similar with Michael but it is NOT what we want to count.
3

CSE 231
Spring 2019
Test Cases
Function Test getgender:
Input:Abraham,Ralph ROutput:male
Input:Adams,Alma DOutput:female
Function Test isMike:
Input:Abraham,Ralph ROutput:False
Input:Bishop,Mike ROutput:True
Input:Cloud,Michael ROutput:True
Input:LujanGrisham,Michelle DOutput:False
male
female
male
male
male
female
Test 1small data:
Input a file name: oops
File not found.
Input a file name: nope
File not found.
Input a file name: test1.txt
Party
Male
Female
Republican
17
0
Democrat 3 5
Dudes named Mike: 1
Do you want to plot? no
Test 2full data:
Input a file name: congress.txt
Party
Male
Female
RepublicanDemocrat
184 147
1792
Dudes named Mike: 18
Do you want to plot? No
4

CSE 231
Spring 2019
Test 3full data plot:
Input a file name: congress.txt
Party
Male
Female
RepublicanDemocrat
184 147
1792
Dudes named Mike: 18
Do you want to plot? YeS
Grading Rubric
Computer Project 05
General Requirements:
Scoring Summary
5 pts Coding Standard 19
5

CSE 231
Spring 2019
descriptive comments, function headers, etc… Implementation:
5 pts openfile function no Mimir test
3 Did not use tryexcept
7 pts getgender function
7 pts isMike function
9 pts Test1
9 pts Test2
3 pts Test3 plotting no Mimir test
Note: hard coding an answer earns zero points for the whole project10 points for not using main
6

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 R data structure python database graph statistic CSE 231
30 $