Plan And Code A Golf Game In Python


You are to plan and then code a golf game program in Python 3, as described in the following information and sample output. Use simple functions, selection and repetition. However, it is important to note that you are not to define any of your own classes or use lists or dictionaries.

Program Features:

Ensure that your program has the following features, as demonstrated in the sample output below:

  • a welcome message with your name in it
  • a menu for the user to view the instructions, play the game or quit
  • a play game option (details below)
  • the program is to return to the menu and loop until the user chooses to quit
  • all inputs should be error-checked by the program as demonstrated in the sample output Playing the game:
  • For each swing, the player chooses a club and then the program generates the distance hit for each shot, updating the distance to the hole accordingly. Play proceeds until the ball is in the hole (distance to the hole is zero), and then the program informs the user of their score.
  • The player has three clubs to choose from for each shot. Each club hits the ball a set average distance, but the actual distance randomly varies between 80% and 120% of the average. The clubs and their average distances are:
  • Driver: 100m (actual distance will be a random number between 80 and 120)
  • Iron: 30m
  • Putter: 10m* *When the ball is inside 10m and the putter is used, the shot will be between 80% and 120% of the distance to the hole, not the club’s average distance. The minimum distance the putter can hit is 1m (no 0m hits). All distances are whole numbers.
  • If an invalid club is chosen, this is counted as an air swing and the number of shots increases by one, but the ball doesn’t move.
  • The ball cannot be a negative distance to the hole. Whether it is in front of or behind the hole, it is still a positive distance to the hole. Python has an abs (absolute value) function that you can use to help with this.
  • The score is the number of shots taken to get the ball in the hole. The final output shows the number of shots taken and how this relates to par. Less than 5 (par for this hole) is “under par”, equal to 5 is called “par”, and more than 5 is “over par”. See sample output for exact outputs


Write up the algorithm in pseudocode – first! Please do this in a docstring (comment) at the top of your code file after your name, date and brief program details. Follow the guide to good pseudocode and examples presented in the subject to ensure this is done to a high standard.



The question belongs to Programming and it discusses about preparing and writing a code for a game in Python. The output file has been attached along with the question document.

Total Word Count NA

Download Full Solution


  • HWA

    this is a very good website

  • HWA

    I have 50 questions for the same test your page is showing only 28

  • HWA

    hi can you please help or guide me to answer my assignments. thanks

  • HWA

    hi can anyone help or guide me to my assignments. thanks

  • HWA

  • HWA

    This solution is perfect ...thanks

  • HWA

    Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes

  • HWA

    Perfect bank of solution. 

  • HWA

    great !

  • HWA
    Paul Brandon-Fritzius

    thanks for the quick response. the solution looks good. :)

  • HWA
    tina Johnson

    thnx for the answer. it was perfect. just the way i wanted it. 

  • HWA

    works fine.