Penalty Shootout

soccerFor this challenge you are going to write a computer program where the user tries to score a goal against the computer.

The user will be asked where do they want to shoot and will have to choose one of the following five options:

  • TL: Top Left,
  • BL: Bottom Left,
  • M: Middle,
  • TR: Top Right,
  • BR: Bottom Right.

football-goal

The computer will act as the goal keeper and randomly choose one of these options too.

The program will decide if there is a goal or not by comparing the user’s choice with the computer option.

Complete the code


We have started the code for you. You need to complete it further:

Video Tutorial


Extension Task 1:


Create a second level where the computer can block up to two locations which are next to each other such as:

  • Bottom left and right left,
  • Bottom left and middle,
  • Top right and middle,
  • etc.

Extension Task 2:


Give the end-user a choice: do they want to shoot the penalty or be the goal keeper? Adapt your code to cater for both options.

Extension Task 3:


Create a program where the computer and the player take it in turn. The program adds up the scores and stops on a best of 5 scores. (e.g. 3-0, 4-1, 4-2, 5-3, 5-4)

Share Button
Posted in Computer Science, Python - Beginner, Python Challenges Tagged with: ,

Our Latest Book