Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Language: Python Program used: PyCharm Interpreter: 3.6.1 at ~/anaconda/bin/python ----- ----- Starter code: https://pastebin.com/NgrECZQ7 candidates_2016: https://www.dropbox.com/s/oc8ws0qfz01664n/sk_election_candidates_2016.csv?dl=1 votecounts_2016: https://www.dropbox.com/s/ucgaf263q2x3qrm/sk_election_votecounts_2016.csv?dl=1 ----- YOU JUST NEED QUESTION #9 FROM
Language: Python
Program used: PyCharm
Interpreter: 3.6.1 at ~/anaconda/bin/python
-----
-----
Starter code: https://pastebin.com/NgrECZQ7
candidates_2016: https://www.dropbox.com/s/oc8ws0qfz01664n/sk_election_candidates_2016.csv?dl=1
votecounts_2016: https://www.dropbox.com/s/ucgaf263q2x3qrm/sk_election_votecounts_2016.csv?dl=1
-----
YOU JUST NEED QUESTION #9 FROM THE STARTER CODE PROVIDED ABOVE.
-----
Flowchart: https://www.dropbox.com/s/kb3fo1nkgozxwkr/infoflow.pdf?dl=1
-----
Question 9 (8 points): Purpose: To practice building applications out of functions. Degree of Difficulty: Moderate. You'll have to move the data around from function to function. All right. Now let's put all the pieces together, and show that we've got everything working Task: Write a few lines of Python after all your function definitions from above that will Open the provided vote count file (sk_election_votecounts_2016.csv) with read party_names . Open both provided files (sk_election candidates_2016.csv) and (sk_election_votecounts_2016.csv) with read election files (). Remember that this function is supposed to return a tuple! . Construct the district database with index all_districts Find the winner in every district with find all1 winners Write the election results to a file with write-election-results The final task is to determine which party won the election and to print to the console a report summarizing the election results. Your program should generate and print a report that has the names of all the parties the number of districts won by each party, the winning party and the number of districts the winning party claimed. You can decide to print this information however you wish, but keep in mind that lists would be especially well suited to store all the party names and dictionaries would be especially well suited to store the number of districts each party won. If you choose to enter the districts won by each party into a dictionary, you can use your find winner function from question 4 to display the winning party. Your summary report may Look like this: Election summary Participating parties: ['GP 'LIB' 'NDP', 'PC', 'SK', 'WIP', 'IND'] Districts won by each party: ['NDP': 10, 'SK' 51) SK won the election with 51 districts After running your program, check the election results file to make sure there is a winning party and can- didate declared for every district. Make sure the winning number of votes is reasonable At this point, you should have a working program that reads the data from the given files, and creates a new file containing the election results. You may still have some testing code in your program, which you should comment out (don't delete it until you're ready to hand in your work - you never know if it might be useful) As a final note, your application could very easily be expanded to analyze more aspects of elections like voter turnout or voter swing. Consider the types of changes you would need to make to the internal data structures to accommodate these featuresStep by Step Solution
There are 3 Steps involved in it
Step: 1
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