Advertisement
Guest User

Task1

a guest
Dec 9th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.40 KB | None | 0 0
  1. """
  2. functions that i will need
  3. -read file
  4. - a function to sort the read file list
  5. - a function to print the judges votes
  6. - a function togather all votes into one list or dictionary, --> dct better
  7. - a function to sort the whole list, the other way around(presenteer gives the votes the other way around)
  8. - a function of the presenter presenting this global list but maximum ten of them
  9. """
  10. import time
  11.  
  12.  
  13. list_of_judges_votes = []
  14.  
  15. def read_file(filename):
  16.     f = open(filename)
  17.     f.close()
  18.  
  19.  
  20. #f = open("Judge8.txt", "r")
  21. #f.close()
  22.  
  23.  
  24. def welcome_Judge(number):
  25.     return"Hello Judge%s. Can we have your votes please?" %(number)
  26.  
  27.  
  28.  
  29. def Judge_read(judge_number):
  30.     print"Hello Amsterdam! Here are my votes:"
  31.     list_of_judges_votes = []
  32.     f = open(judge_number, "r")
  33.     for line in f:
  34.         data = line.split()
  35.         list_of_judges_votes.append(data)
  36.     return list_of_judges_votes #puts local variable outside in order to become global variable
  37.  
  38.  
  39. reverse = None
  40. def sorting(lst):
  41.     return sorted(lst, key=lambda x: float(x[1]))
  42.  
  43.  
  44.  
  45.  
  46. def print_statement(lst):
  47.     for item in range(len(lst)):
  48.         #time.sleep(1.5)
  49.         print"%s: %s" % (lst[item][0], lst[item][1])
  50. #print Judge_statement("Judge11.txt")
  51.  
  52.  
  53. print print_statement(list_of_judges_votes)
  54. def goodbye_Judge(number):
  55.     return "Thank you Judge%s" %(number)
  56.  
  57.  
  58.  
  59.  
  60. print"Welcome to the Eurosong Contest!"
  61.  
  62. print welcome_Judge(1)
  63. list2 = Judge_read("Judge1.txt")
  64. print_statement(list2)
  65.  
  66.  
  67. sorting2 = sorting(list2)
  68. print sorting2
  69. print_statement(sorting2)
  70. print goodbye_Judge(1)
  71.  
  72.  
  73. #i need to create a function that adds the points of the judges scores, however i dont know how to do it
  74. def points_added(lst):
  75.     #check if the string is part of the dictionary or not, (the key), if it isnt add it to the dictionary with that value, if it is that key plus equals that vote
  76.    
  77.     for item in range(len(lst)):
  78.        
  79.         print"%s: %s" % (lst[item][0], lst[item][1])
  80.  
  81. #here i am trying to find a way to add the existing scores of the countries to the next scores that the next judge will give, but currently i cant find a way to do it, probably will need a dictionary?
  82. res = list()
  83. for j in range(0, len(list2[1])):
  84.     tmp = 0
  85.     for i in range(0, len(list2)):
  86.         tmp = tmp + (int(list2[1]))
  87.     res.append(tmp)
  88. print str(res)
  89.  
  90.  
  91.  
  92.  
  93. #split string(list) --> takes list as an argument
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement