Question: Use python please, sample set of ballot papers in picture 2,candidates file in picture 3, output should look like picture 4. Thank you Deciding the

Use python please, sample set of ballot papers in picture 2,candidates file in picture 3, output should look like picture 4. Thank you  Use python please, sample set of ballot papers in picture 2,candidates
file in picture 3, output should look like picture 4. Thank you
Deciding the Election The following algorithm is used to decide who has
won the election. The number of papers remaining after informal votes have

Deciding the Election The following algorithm is used to decide who has won the election. The number of papers remaining after informal votes have been removed is the pool of "elegible vote 1. In the first step, the first preferences from all the votes are counted. If a candidate secures at least 50% of the eligible votes, that candidate is declared elected and no further counting is done 2. If no candidate has secured an absolute majority (i.e. minimum 50% of the elegible votes, plus 1, the candidate with smallest tally is eliminated from further counting, and that candidate's preferences are added to the counts of the remaining candidates. If a candidate now has an absolute majority the votes, that candidate is declared elected. Otherwise, Step 2 is repeated: The candidate with smallest number of votes is eliminated and the next-preference votes redistributed among the remaining candidates. That is, for each vote associated with the eliminated candidate the current top preference (for the eliminated candidate) is removed and the next preference is instead associated with the next most favoured candidate. However, if the next most favoured candidate has also been eliminated, the preference is popped and the preference after that should be used, and so on. If all the preferences for a papers have been used, the vote is regarded as "spent and discarded 4. In the event of a tie for smallest count, the Act provides for the Returning Officer, i e. person in charge of the count o, first, recount and then, if the tie remains, to make a random choice among the candidates who have equal smallest counts. For this Project, however, please choose for elimination the candidate nearest the top of the list of candidates. (This provides reproducible behaviour when testing Optional Preferential Optional Preferential Voting is to also be modelled in this Project. Optional Preferential Voting is simply the voting method that allows incomplete ballots to be accepted, so long as at least one candidate receives a vote. In other words, if there are 5 candidates in the election for a seat, an elector can number, say, 3 squares, so long as no two squares have the same number and no numbers from 1 to 3 are missing Your Program Your program must contain a definition for the function main, starting with def main candidates file ballots file name optional False this case, the As in Projectl, main will be used to call your code durin g automated testing. However, call to main will also be used to provide the file-name for the file of candidates names and the file-name of the file of ballots. Your program should therefore NOT call input The file containing names of candidates is exactly as per Projectl: one name per line The votes, i.e. papers, will be in a comma separated file, e.g 1, 3, 4, 5, 2 indicating that Candidate 1 has the first preference, Candidate 5 has the second preference Candidate 2 has the third preference, etc. Other lines will look like: 2, 1, 3, 5, 4 1, 3, 4, 5, 2 3, 5,2, 4,1 1, 4, 5, 2, 3 If optional preferential voting is allowed, these votes are also formal

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!