The objective of this analysis is to assist Colorado Board of Elections employee with an election audit for a recent local congressional election following the steps below;
total_votes
was set to 0
and iterated through each row and increments by 1
A breakdown of the number of votes and the percentage of total votes for each county in the precinct was determined by creating a county list and county votes dictionary county_names = []
and
county_votes = {}
and tracking the largest county and county voter turnout winning_county = ""
winning_votes = 0
, as well as running a for loop
to retrieve vote count and percentage, calculate the percentage of votes for the county using the script vote_percentage_county = float(votes_county)/float(total_votes) * 100
and printing the the county results using an f" string
function. An if statement
was looped into the above for loop
to determine the winning county and get its vote count
for loop
above, the veriable winning_county
was nested into the f" string
(
f"------------------------------\n"
f"Largest County Turnout: {winning_county}\n"
f"------------------------------\n"
)
and the winning county was printed and saved to a .txt
file.if statement
was looped into another for loop
to determine the number of votes and the percentage of the total votes each candidate received and initializing a varable candidate_results
to be equal to an f" string
the result was printed and saved to a .txt
fileBelow is a breakdown of the election results
Election Results
## Election-Audit Summary The python script written for this analysis can be used to perform analysis for other elections by;
row[i]
in the for loop
.f" string
can also be formatted to show several election variables