Question: I am completing a pairwise comparison using Python 2 in Jupyter Notebook, from some imported data and have gotten to the final scores. I am

I am completing a pairwise comparison using Python 2 in Jupyter Notebook, from some imported data and have gotten to the final scores. I am having trouble creating the final code that will print out the the winner (highest points). The code also needs to take the chance of the candidates tying into consideration. Please help, coding is not my expertise!
In [9]: | # define function to compare two given candidates def comparison(s,t): # compares the two candidates & sets the candidate with Lowest score for o in range(len(votes)): for k in range(len(votes[e])): if votes[0][k] s: lowest[k] -s elif votes[o][k] -t lowest[k] t # sets temporary score for m in range(len(lowest)): if lowestm]: score one[t]NOV[m] score_one[s]NOVIm] if score ones> score onerti else: # rewards one point to the winning candidate score s] +1 elif score onetl score oners: score t]+ 1 # rewards half a point if candidates tie else: score [5] score [t] 0.5 8.5 += # score reset for ele in [e,1,2,3,4] score_one[s] e score_one[t]e # compare all possible combinations comparison('A, B) comparison('A, C) comparison('A, D) comparison('B, 'C') comparison'B, D) comparison('C, D) print (score) 'A: , C 3, B 2, D 1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
