Question: 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 #5 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 #5 FROM THE STARTER CODE PROVIDED ABOVE.
Question 5 (4 points): Purpose: To practice using data stored in dictionaries (databases, mappings) Degree of Difficulty: Easy to Moderate. Stay organized! Task: Write a function named find all_winners that takes one argument: a district database (i.e., a dic- tionary as returned by index_all_districts from Question 3, above) containing every electoral district record. The function should find the winning party in each electoral district then add a new key-value pair to each district's record: the new key will be 'Winner, and its value will be the name of the winning party for that district. Details: Note that this function does not return anything - it simply modifies each district voting record by adding a new key-value pair. You'll want to use the functionfind_winner ) on each district's voting recoro. Example: Given the following district database 'Arm River': - Name: Arm River' 'Candidates' 'LIB' 'Russ', 'NDP': 'Denise 'PC''Raymond', 'SK': 'Greg'^, Votes f'LIB': 207, NDP 1457, 'PC': 338, 'SK': 6187 , Athabasca': 1 'Name': 'Athabasca', 'Candidates''LIB': 'Michael', 'NDP': 'Buckley', 'PC':', 'SK': 'Philip'^, 'Votes': f'LIB': 262, 'NDP': 1756, 'PC': 0, 'SK' 644 Your function will modify it so that it has the following structure Arm River': Name: Arm River' 'Candidates''LIB''Russ' 'NDP': 'Denise' PC'Raymond', 'SK'Greg'h Votes':'LIB':207, NDP :1457, PC'338, 'SK': 6187, Winner': 'SK' , Athabasca ': Name' : 'Athabasca' , 'Candidates''LIB''Michael', 'NDP'Buckley ', 'PC'', 'SK Votes':'LIB':262, NDP:1756, PC': 0, SK:644 Winner: NDP' 'Philip', Testing: Before going on, you want to be sure that your function works properly. The starter file has the testing code, but it will be initially part of a comment. Uncomment the testing for this question while you are working on it and comment it out when you are finished. The actual console output is very long and difficult to read, but you should see a difference in the ouput before and after your function is called. In particular, every district in the database should have a new key named Winner" with the value being the name of the party with the most votes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
