Read and extract CVS files; differentiation of python data types - integers, floating-point decimal numbers, strings; perform mathematical operations using data types; declare variables using different data types; create and use data structures like lists, tuples, and dictionaries; create and use decision and repetition statements; create and use Boolean and logical operators; write data to an output file and print the file; create scripts that read, write, and store data from files or in arrays; use decision statements, logical operations for complex comparisons, and repetition statements to run code more than once; produce screen outputs; code refactoring
Assiating a Board of Elections employee with completing an election audit of a recent local congressional election. Purpose of audit was to determine winning candidate and largest voter turnouts based on county. Deliverable 1: The election results printed to the Command Line, Deliverable 2: The election results saved to a text file, Deliverable 3: A written analysis of the election audit (README)
- Calculate the total number of votes cast.
- Complete list of counties that had a turnout.
- Calculate the voter turnout for each county.
- Calculate the percentage of votes each county cast.
- Identify the county with the highest turnout.
- Complete list of candidates who recieved votes.
- Calculate the total number of votes each candidate recieved.
- Calculate the percentage of votes each candidate won.
- Determine the winner of the election based on popular vote.
- Jefferson: 38,855 – 10.5%
- Denver: 306,055 – 82.8% (Largest number of votes)
- Arapahoe: 24,801 – 6.7%
- Charles Casper Stockham: 23.0% (85,213)
- Diana DeGette: 73.8% (272,892) – Winner
- Raymon Anthony Doane: 3.1% (11,606)
- The code can be applied year after year to calculate the result breakdown but it can be refactored to analyze more data by shifting the columns variables that is looking for to use in the calculations.
- The script can be used as a template to analyze election data on a larger scale from more than just counties through a modification of ingesting multiple files and creating a combined database.