Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python:: How do I implement a file into python so it will pull it from my desktop to allow the program to work properly?

In python:: How do I implement a file into python so it will pull it from my desktop to allow the program to work properly?

Note that this is an exercise rather than a test. If you get stuck, feel free to contact me and ask questions.

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.

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Explain the following: Hadley cells, jet streams, Coriolis effect.

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago