Advertisement
Dunkmax

Untitled

Apr 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #function that reads the text file and creates a list with all the information
  2.  
  3.  
  4. myFile = open ("premier.csv")
  5.  
  6. myFile.readline()
  7. myFile.readline();
  8. league = []
  9. for line in myFile:
  10. line = line.split(',')
  11. points = int(line[2])*3 + int(line[3])
  12. line.append(points)
  13. league.append(line)
  14.  
  15.  
  16. #function that given a team returns the current points, -1 if the team is not found
  17. def getPoints(name, league):
  18. for team in league:
  19. if name in team[0] :
  20. return(team[5])
  21. return -1
  22.  
  23. #function that returns the information of the teamm with the highest score so far
  24. def highestScore(league):
  25. winner = league[0]
  26. for team in league:
  27. if team[5] > winner[5]:
  28. winner = team
  29. return(winner)
  30.  
  31.  
  32. from tkinter import *
  33.  
  34. def ImpPoints() :
  35. Points.set(getPoints(name.get(),leagueOne.get()))
  36.  
  37. root= Tk()
  38. root.title("League Points Calculator")
  39.  
  40. Label(root, text="name").grid(row=0, column=0)
  41. name = StringVar()
  42. Entry(root, textvariable=name).grid(row=0, column=1)
  43.  
  44. Label(root, text="leagueOne").grid(row=1, column=0)
  45. leagueOne = StringVar()
  46. Entry(root, textvariable=leagueOne).grid(row=1, column=1)
  47.  
  48. Label(root, text="Points").grid(row=2, column=0)
  49. Points=IntVar()
  50.  
  51. Label(root, textvariable=Points).grid(row=2, column=1)
  52.  
  53. button = Button(root, text="getPoints", command=ImpPoints)
  54. button.grid(row=3, column=0, columnspan=2)
  55.  
  56. root.mainloop()
  57.  
  58.  
  59.  
  60. English Premier League
  61. Team Matches Matches Won Matches Drawn Matches Lost
  62. Manchester City 30 26 3 1
  63. Arsenal 30 14 6 10
  64. Leicester City 30 10 10 10
  65. Manchester United 30 20 5 5
  66. Tottenham Hotspur 30 18 7 5
  67. West Ham United 30 7 9 14
  68. Southampton 30 5 13 12
  69. Crystal Palace 30 6 9 15
  70. Everton 30 10 7 13
  71. Liverpool 30 17 9 4
  72. Watford 30 10 6 14
  73. Stoke City 30 6 9 15
  74. West Bromwich Albion 30 3 11 16
  75. Swansea City 30 8 7 15
  76. Burnley 30 11 10 9
  77. Chelsea 30 17 5 8
  78. Brighton & Hoven Albion 30 8 10 12
  79. Bournemouth 30 8 9 13
  80. Newcastle United 30 8 8 14
  81. Huddersfiel Town 30 8 7 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement