Jupyter notebook coursenotes/Topic2/Topic2_exercise2.ipynb
Lab exercise 2:
The file PremierLeague2011.txt contains a list of all fixtures played in the Barclays Premier League between 13th August 2011 and 12th December 2011.
The data in the file looks like (this example is the first line in the file):
13/08/2011 2 19 1 2 A
where:
Item | Description |
---|---|
13/08/2011 | is the date that the match was played (not needed) |
So, e.g. in this case, on 13th August 2011, team 2 (Blackburn, at home) lost 1-2 to team 19 (Wolves, away)
** Note ** To make this assessment easier, the teams have been ordered alphabetically and each team has been given a team code which is a positive integer from 0 to 19 as follows:
0: "Aston Villa" 1: "Arsenal" 2: "Blackburn" 3: "Bolton" 4: "Chelsea" 5: "Everton" 6: "Fulham" 7: "Liverpool" 8: "Man City" 9: "Man Utd" 10: "Newcastle" 11: "Norwich" 12: "QPR" 13: "Stoke" 14: "Sunderland" 15: "Swansea" 16: "Tottenham" 17: "West Brom" 18: "Wigan" 19: "Wolves"
Create a PremierLeagueTeam (or similar named)
class
Create instances of this
class
for all 20 teamsAdd methods to the
class
to to keep track of each team’s match statistics, i.e.:
total number of matches played
total number of matches won
total number of matches drawn
total number of matches lost
total number of goals scored
total number of goals conceded
total number of points (where a win is worth 3 points and a draw is worth 1 point)
Print out a copy of the Premier League table as it stood on 12th December 2011. Note that teams with the same number of points are ordered by goal difference. The table will look like:
(First 3 lines) Team PL W D L GF GA PTS Man City 15 12 2 1 49 15 38 Man Utd 15 11 3 1 35 14 36 (Last 2 lines) Blackburn 15 2 4 9 22 34 10 Bolton 15 3 0 12 20 36 9