Git Product home page Git Product logo

python's Introduction

Election Audit Analysis

Overview of Election Audit

The Colorado Board of Elections has asked for an audit of the tabulated election results for US Congressional precinct in Colorado. In this project we are teaming up with Tom, a Colorado Board of Elections' employee and Seth, Tom's manager, to create an automated audit using Python. The three primary voting methods included in this data are mail-in ballots, punch cards, and direct recording electronic (DRE) counting machines. The election results produced by the code include total vote count, county vote counts, largest county turnout, candidate vote count, and the winning candidate vote count and percentage. These results from this election audit will be submitted to the election commission for review. The overall goal is for this code to not only audit the congressional district elections but to audit senatorial districts and local elections as well.

Analysis and Challenges

The election_results.csv file was downloaded and read into Python 3.10.4 Visual Studio Code 1.65.2.

SS0

Step 1: Initialized a county list that will hold the names of the counties and a dictionary that will hold the county as the key and the votes cast for each county as the values.

SS1

Step 2: Initialized an empty string that will hold the county names for the county with largest turnout and a variable that will hold the number of votes of the county that had the largest turnout.

SS2

Step 3: Created a for loop that reads the election results and produces the names of the county from each row.

SS3

Step 4: Created a decision statement with a logical operator to check if the county name in Step 3 is located in the county list created in Step 1.

SS4

Step 5: Created a second decision statement that tracks each county's vote count and adds the results to the dictionary created in Step 1.

SS5

Step 6a-d: Created a repetition statement to get the county from the county dictionary created in Step 1 and prints a statement with the current county, its percentage of the total votes, and its total votes to the command line.

SS6 1

Step 6e-f: Created another decision statement that determines the county with the largest vote count and then adds that county and its vote count to the variables created in Step 2.

SS6 2

Step 7: Created a final print out statement with the county with the largest turnout.

SS7

Step 8: Created a for loop that saves the largest county turnout, each candidate's vote count and percentage, and the winning candidate vote count and percentage to a text file.

SS8

Election-Audit Results

  • There were 369,711 votes casted in this congressional election.
  • Number of votes and percentage of total votes for each county in the precinct:
    • Jefferson: 38,855 votes; 10.5%
    • Denver: 306,055 votes; 82.8%
    • Arapahoe: 24,801 votes; 6.7%
  • Denver had the largest number of votes.
  • The number of votes and the percentage of the total votes each candidate received:
    • Charles Casper Stockham: 85,213 votes; 23.0%
    • Diana DeGette: 272,892 votes; 73.8%
    • Raymon Anthony Doane: 11,606 votes; 3.1%
  • Diana DeGette won the election with 272,892 votes which is 73.8% of the total votes.

Election-Audit Results On Text File

textfileSS

Election-Audit Results In Terminal

terminalSS

Election-Audit Summary

This script can be used, with modifications, to produce results for any election. For example, with local elections, the code can be modified to break down the number of votes and percentage by city within each county. Also with senatorial district elections, the code can be modified to break down the voting statistics not only by county but by voting district. The code can also be modified to show the percentage of vote based on political parties, rural vs urban areas, and age group. The potential of this code could be an easy, automated solution for all future election audit analysis needs.

python's People

Contributors

ksommerdorf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.