Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions