Question: Python Programming Task 2.12.1: Write a procedure create voting dict(strlist) that, given a list of strings (voting records from the source file), returns a dictionary
Python Programming
Task 2.12.1: Write a procedure create voting dict(strlist) that, given a list of strings (voting records from the source file), returns a dictionary that maps the last name of a senator to a list of numbers representing that senators voting record. You will need to use the built-in procedure int() to convert a string representation of an integer (e.g. 1) to the actual integer (e.g. 1).
Task 2.12.2: Write a procedure policy compare(sen a, sen b, voting dict) that, given two names of senators and a dictionary mapping senator names to lists representing voting records, returns the dot-product representing the degree of similarity between two senators voting policies.
Task 2.12.3: Write a procedure most similar(sen, voting dict) that, given the name of a senator and a dictionary mapping senator names to lists representing voting records, returns the name of the senator whose political mindset is most like the input senator (excluding, of course, the input senator him/herself).
Task 2.12.4: Write a very similar procedure least similar(sen, voting dict) that returns the name of the senator whose voting record agrees the least with the senator whose name is sen.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
