Cup draw

Cup draw

Random draw for a competition.

Competitions often include a first round where teams are drawn against each other randomly.

Make


Write a program that allows the user to enter any number of team names. The computer shuffles the teams and then outputs all the team names two at a time. If there are an odd number of teams, the word "bye" is added to the list so that one team gets an automatic place in the second round. You only need to simulate the draw for round one.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called `input_teams` that:

  1. Asks the user to input two teams.
  2. Appends the two teams to a list of teams.
  3. Asks the user if they want to enter two more teams.
  4. If the user inputs "y" the process of inputting and appending teams is repeated until the user inputs "n".

Complete the subprogram called `draw_teams` that:

  1. Shuffles the teams.
  2. Outputs a message, "The draw is:"
  3. Outputs who plays whom.

Complete the `main program` so that:

  1. An empty list called, "teams" is declared.
  2. The input_teams procedure is called.
  3. The draw_teams procedure is called.

Typical inputs and outputs from the program would be:

Enter the name of a team: England

Enter the name of a team: Germany

Add two more teams? y/n :y

Enter the name of a team: Spain

Enter the name of a team: Italy

Add two more teams? y/n :n


The draw is:

Spain v Germany

England v Italy


Enter the name of a team: Brazil

Enter the name of a team: Uraguay

Add two more teams? y/n :y

Enter the name of a team: Peru

Enter the name of a team: Argentina

Add two more teams? y/n :y

Enter the name of a team: Ecuador

Enter the name of a team: bye

Add two more teams? y/n :n


The draw is:

Brazil v Argentina

bye v Ecuador

Uraguay v Peru

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Run your program several times to check that your program has met the success criteria.

Check that you have:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Craig'n'Dave logo

Craig 'n' Dave

Bett Awards 2024 Finalist