Question
I need to create a python program that performs several function on this dictionary I have a nested dictionary { 1: [2, 4, 1, 3],
I need to create a python program that performs several function on this dictionary
I have a nested dictionary { 1: [2, 4, 1, 3], 2: [1, 3, 2, 4], 3: [4, 3, 1, 2], 4: [1, 3, 4, 2], 5: [2, 3, 4, 1], 6: [3, 1, 2, 4] }
def fun 1()it has 3 inputs. First is the dictionary, next is a value assigned to each number on the list which equals to the length of the list. So for List 1: number 2 has a value 4, number 4 has a value 3, number 1 has a value 2 and number 3 has a value 1, so each number gets assigned a value based on there place in the list. So it becomes
1: [(2,4,) (4,3) (1,2) (3,1)]. Then after it does that on all the list i need to take out the numbers with the value 4 from each list and then the number with that appears the most is the winner. And the last input is the function for a tie break
def fun2 () Two inputs one dictionary and next is the tie breaking. This function finds the winner based on the fact which number appeared in the first position of the list most often will become the winner and if its 2 number we use tie breaking option.
def fun3() Two inputs one dictionary and next is the tie breaking. This function assigns 0 value to every number that is in the last place of each list, and 1 to the rest of the others. The winners is the number which has the highest tally of 1 combined. So in this list both 3 and 1 have equal tally of 1 but 3 is bigger so its the winner.
def fun4() Two Two inputs one dictionary and next is the tie breaking. This function assigns value of 0 to the last item in the list. A value of 1 to the second last and value of m-1 to there favorite where m is the length of the list. The winner is again the number that has the highest value combined from each list.
def fun 5() Two Two inputs one dictionary and next is the tie breaking. This function assigns value of 1/m to there least favorite a 1 to there favorite. In other words a number at position j has a value of 1/j. The winner is again the number that has the highest value combined from each list.
def fun 6() Two Two inputs one dictionary and next is the tie breaking .The voting rule works in rounds. In each round, the alternatives that appear the least frequently in the first position are removed, and the process is repeated. If two items we use tie breaking
Step 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