Question
The total number of votes cast A complete list of candidates who received votes The percentage of votes each candidate won The total number of
The total number of votes cast
A complete list of candidates who received votes
The percentage of votes each candidate won
The total number of votes each candidate won
The winner of the election based on popular vote
The result like this
Election Results ------------------------- Total Votes: 369711 ------------------------- Charles Casper Stockham: 23.049% (85213) Diana DeGette: 73.812% (272892) Raymon Anthony Doane: 3.139% (11606) ------------------------- Winner: Diana DeGette -------------------------
this is my code
import os
import csv
#set the path to the csv file
csvpath = os.path.join('..','Resources','election_data.csv')
#open the csv file and read through the rows
with open(csvpath) as csvfile:
reader = csv.reader(csvfile, delimiter=',')
#count for total number of votes cast
#skip the header row
header = next(reader)
#variables
count = 0
percentage_votes = 0
total_number = 0
candidate = ""
winner = ""
#candidates who received votes
candidate_received_votes = [0,0,0]
#candidates list
candidate_list = ["Charles Casper Stockham","Diana DeGette","Raymon Anthony Doane"]
# loop through the rows in the csv file
help me finish the for loop and while loop
Ballot ID County 1323913 Jefferson 1005842 Jefferson 1880345 Jefferson 1600337 Jefferson 1835994 Jefferson 1772756 Jefferson 1920023 Jefferson 1040408 Jefferson 1018414 Jefferson 1361118 Jefferson 1045722 Jefferson 1006975 Jefferson 1489642 Jefferson 1456389 Jefferson 1936969 Jefferson 1356658 Jefferson 1651667 Jefferson 1833621 Jefferson 1730001 Jefferson 1059252 Jefferson 1279893 Jefferson 1100426 Jefferson 1855823 Jefferson 1951080 Jefferson 1345091 Jefferson 1113764 Jefferson 1366270 Jefferson 1431431 Jefferson 1402951 Jefferson 1708981 Jefferson 1245209 Jefferson 1046171 Jefferson 1418131 Jefferson 1713581 Jefferson 1353343 Jefferson 1176460 Jefferson Candidate Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S Charles Casper S
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import os import csv Set the path to the CSV file csvpath ospathjoinResources electiondatac...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started