Football Results Tracker

football-soccer-ballYou have been asked to create a program to keep track of the scores from the football Premier League.

Your program will store match results in a text file using the following format:

home team;away team;home score;away score;

For instance, after a few games your text file may contain the following information:

Chelsea;Everton;2;0;
Liverpool;Arsenal;4;0;
Crystal Palace;Swansea City;0;2;
Newcastle United;West Ham United;3;0;
Manchester United;Leicester City;2;0;
Manchester City;Everton;1;1;
Swansea City;Manchester United;0;4;
Liverpool;Crystal Palace;1;0;

To complete this challenge you will need to read more about how to read through a CSV file.

Task 1:


Your program should include:

  • An option to input and append a new line / match score to the text file. To do so the program will:
    • Ask the user to input the name of the Home team,
    • Ask the user to input the name of the Away team,
    • Ask the user to input the Home Score (number of goals scored by the home team.),
    • Ask the user to input the Away Score (number of goals scored by the away team.),
    • Append all this information at the end of the text file.

Task 2:


Create another option where the program will:

  • Ask the user to display all the scores on screen using the following format:

Home Team – Home Score:Away Score – Away Team

Task 3:


Create a third option where the program will:
  • Allow the user to enter a team name to display all the results of this team.
  • Calculate and display the number of points of a team; knowing that a team scores 3 points for a win, 1 point for a draw and 0 point for a loss.

Top-Down Modular Design


This diagram represents the main components of our system:
top-down-modular-design-football-tracker

Python Code


We have started the code for you by implementing a basic menu structure. You task is to implement the code for each one of the three options:

Solution

Task 1: View Solution
Task 2: View Solution
Task 3.a: View Solution
Task 3.b: View Solution
Share Button