HugeBob

DRP Primary Voting Machine 1

Jun 15th, 2021
669
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2.  
  3. import xlrd
  4.  
  5. data = xlrd.open_workbook('C:/Users/wesle/Desktop/Code/DRP Voting Machine/data.xls')
  6. sheet = data.sheet_by_index(0)
  7.  
  8. candidates = ["Adam Pendergrass","Tealeaf","SGE24","Outpacing"]
  9. points = [0,0,0,0]
  10. awards = [4,3,2,1]
  11. voted = [False,False,False,False]
  12.  
  13. row=1
  14. col=2
  15. cols = sheet.ncols
  16. while(row < sheet.nrows):
  17.     while(col<cols):
  18.         c=0
  19.         while(c<len(candidates)):
  20.             if(sheet.cell_value(row,col) == candidates[c]):
  21.                 points[c] = points[c] + awards[(col-2)]
  22.                 if(voted[c]):
  23.                     print(sheet.cell_value(row,1)+" has a voting irregularity!")
  24.                     exit()
  25.                 voted[c] = True
  26.                 c=0
  27.                 break
  28.             c = c + 1
  29.         c=0
  30.         col = col + 1
  31.     row = row + 1
  32.     col = 1
  33.     voted = [False,False,False,False]
  34.  
  35. i=0
  36. while(i<len(candidates)):
  37.     print(candidates[i]+" received "+str(points[i])+" points!")
  38.     i = i + 1
  39.  
  40. print("\nDRP Primary Voting Machine by Mooshroom!")
RAW Paste Data