Tom and Seth have a data set holding the result of a vote. We need to analyze the data to find out the election result. To break down, we need total vote cast; vote cast of each county; Candidates' result; who is the winner.
-
Total Votes: 369,711
-
County Votes:
- Jefferson : 38,855 (10.51%)
- Denver : 306,055 (82.78%)
- Arapahoe : 24,801 (6.71%)
-
Largest County Turnout:
- Denver (306,055)
-
Candidate Result:
- Charles Casper Stockham: 23.0% (85,213)
- Diana DeGette: 73.8% (272,892)
- Raymon Anthony Doane: 3.1% (11,606)
-
Winning Detail:
- Winner: Diana DeGette
- Winning Vote Count: 272,892
- Winning Percentage: 73.8%
In this Challenge, Python os and csv modules are imported. If another similar analysis will be performed, the data should be save into the Resources file, and the Path in the code should be modified.
For any election data, having the second column as Region name, and the third column as the candidates' name, we can run this code. Just replace 'County' with other region unit. (like Community, Class, Cities, etc.)
If there's no county/region information, this code could also reusable. From line94 to line121, all the County analysis should be removed. As well as line 89 (f"County Votes:\n") should be removed as well.