nickjlupu / Election_Analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Election_Analysis

Project Overview

This is the week 3 challenge for the Data Analytics Bootcamp. The class was tasked with adding features to the python code developed throughout the class modules for this week. The code that was provided read data from a csv file, determined the votes cast for each candidate, determined a winner based on popular vote, and displayed these on the terminal as well as in a .txt file. The specific instructions:

  1. Make a copy of the PyPoll.py file that you used throughout this module and rename it PyPoll_Challenge.py.
  2. Create a list for the counties.
  3. Create a dictionary where the county is the key and the votes cast for each county in the election are the values.
  4. Create an empty string that will hold the county name that had the largest turnout.
  5. Declare a variable that represents the number of votes that a county received.
  6. Inside the with open() function where you are outputting the file, do the following: Create three if statements to print out the voter turnout results similar to the results shown above.
  7. Add the results to the output file.
  8. Print the results to the command line.

Resources

election_results.csv was provided

Software used: Python 3.7.6, Visual Studio Code 1.46.1

Summary

The analysis of the data provided output the following: Election Results Total Votes: 369,711

County Votes: Jefferson: 10.5% (38,855) Denver: 82.8% (306,055) Arapahoe: 6.7% (24,801)

Largest County Turnout: Denver

Charles Casper Stockham: 23.0% (85,213) Diana DeGette: 73.8% (272,892) Raymon Anthony Doane: 3.1% (11,606) Winner: Diana DeGette Winning Vote Count: 272,892 Winning Percentage: 73.8%

Challenge Notes

This challenge included refactoring the code that was developed during the weekly module. Concepts were carried across from these modules and code. A lot of my work was taking the existing code, copy/paste, renaming and declaring new variables, lists, and dicitionaries, then re-organizing the code to get the desired output. This code demonstrates the fundamentals of python syntax, reading from / writing to csv/txt files, for loops, conditionals, lists, and dictionaries.

About


Languages

Language:Python 100.0%