Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #function that reads the text file and creates a list with all the information
- myFile = open ("premier.csv")
- myFile.readline()
- myFile.readline();
- league = []
- for line in myFile:
- line = line.split(',')
- points = int(line[2])*3 + int(line[3])
- line.append(points)
- league.append(line)
- #function that given a team returns the current points, -1 if the team is not found
- def getPoints(name, league):
- for team in league:
- if name in team[0] :
- return(team[5])
- return -1
- #function that returns the information of the teamm with the highest score so far
- def highestScore(league):
- winner = league[0]
- for team in league:
- if team[5] > winner[5]:
- winner = team
- return(winner)
- from tkinter import *
- def ImpPoints() :
- Points.set(getPoints(name.get(),leagueOne.get()))
- root= Tk()
- root.title("League Points Calculator")
- Label(root, text="name").grid(row=0, column=0)
- name = StringVar()
- Entry(root, textvariable=name).grid(row=0, column=1)
- Label(root, text="leagueOne").grid(row=1, column=0)
- leagueOne = StringVar()
- Entry(root, textvariable=leagueOne).grid(row=1, column=1)
- Label(root, text="Points").grid(row=2, column=0)
- Points=IntVar()
- Label(root, textvariable=Points).grid(row=2, column=1)
- button = Button(root, text="getPoints", command=ImpPoints)
- button.grid(row=3, column=0, columnspan=2)
- root.mainloop()
- English Premier League
- Team Matches Matches Won Matches Drawn Matches Lost
- Manchester City 30 26 3 1
- Arsenal 30 14 6 10
- Leicester City 30 10 10 10
- Manchester United 30 20 5 5
- Tottenham Hotspur 30 18 7 5
- West Ham United 30 7 9 14
- Southampton 30 5 13 12
- Crystal Palace 30 6 9 15
- Everton 30 10 7 13
- Liverpool 30 17 9 4
- Watford 30 10 6 14
- Stoke City 30 6 9 15
- West Bromwich Albion 30 3 11 16
- Swansea City 30 8 7 15
- Burnley 30 11 10 9
- Chelsea 30 17 5 8
- Brighton & Hoven Albion 30 8 10 12
- Bournemouth 30 8 9 13
- Newcastle United 30 8 8 14
- Huddersfiel Town 30 8 7 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement