Taking a penalty, in any sport, is partly about the skill in directing the ball, but more about being able to anticipate what your opponent is going to do.

In this activity you're going to write a program to allow the user to take a penalty against the computer, but if you think of the abstraction (the key steps in the program without the detail) you can hopefully see that other games, such as Rock, Paper, Scissors, are very similar in structure.

The user is able to "kick" the ball at one of the five zones shown on the right.  The computer goalkeeper can choose to defend one of the same areas.  Before you start, think about representation and user interface - how will the user enter their choice, and how will it be stored?  How will the computer make its "choice"?

Your Task

Your task is to produce a game that allows users to take a "penalty" against the computer. Your program should:

  1. decide which area of the goal mouth the computer wants to defend
  2. ask the user where they want to "kick" the ball
  3. check whether the computer has "saved" the penalty, or whether the user has scored.  The penalty is saved if both the user and the computer choose the same zone.


Can you reproduce a "penalty shootout", like they have at the end of drawn games in the World Cup?  In that situation the user takes a number (e.g. five) of penalties and they are given a score at the end.

NB. The idea for this game was taken from