Question: {In python} I want this program to be able to pull in a file from the desktop to use. Write a program that allows the

{In python} I want this program to be able to pull in a file from the desktop to use.

Write a program that allows the user to enter the name of the file containing data (in this case votes.txt) about the local election, file has a record of votes received by each candidate. The program should then output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate. The program should also output the winner of the election.

Frye, 1 Miller, 1 Frye, 1 Miller, 1 Miller, 1 Frye, 1 Frye, 1 Miller, 1 Miller, 1 Miller, 1 Miller, 1 Johnson, 1 Frye, 1 Johnson, 1 Miller, 1 Johnson, 1 Johnson, 1 Frye, 1 Frye, 1 Miller, 1 Johnson, 1 Miller, 1 Johnson, 1 Johnson, 1 Frye, 1 Miller, 1 Johnson, 1 Johnson, 1 Miller, 1 Frye, 1 Johnson, 1 Miller, 1 Frye, 1 Miller, 1 Miller, 1 Miller, 1 Miller, 1 Johnson, 1 Johnson, 1 Frye, 1 Frye, 1 Frye, 1 Miller, 1 Miller, 1 Johnson, 1 Johnson, 1 Johnson, 1 Miller, 1 Miller, 1 Johnson, 1 Frye, 1 Frye, 1 Johnson, 1 Johnson, 1 Johnson, 1 Miller, 1 Frye, 1 Miller, 1 Miller, 1 Miller, 1 Johnson, 1 Johnson, 1 Miller, 1 Miller, 1 Johnson, 1 Frye, 1 Frye, 1

Hint: you need to somehow relate a candidate and their votes. A dictionary will work the best but lists will do too. If you are familiar with two-dimensional lists, that's also a possibility.

Example output:

Candidate -- Votes -- % of Total Votes

Frye -- 1500 votes -- 15.0% Johnson -- 5000 votes -- 50.0% Miller -- 3500 votes -- 35.0%

Johnson is the winner!

Total votes: 10000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!