Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Golf Python code Instructions The score on a golf hole is the number of strokes (hitting the ball) taken to get the ball in

Golf Python code

Instructions  

The score on a golf hole is the number of strokes (hitting the ball) taken to get the ball in the hole. "Par" is the number of strokes expected for it to take to get the ball into the hole, e.g.  3, 4, or 5.

We describe the situation on a given hole in a player's game by checking the difference between the par and the actual number of strokes the player took:

"Eagle": number of strokes is two less than par
"Birdie": number of strokes is one less than par
"Par": number of strokes equals par
"Bogey": number of strokes is one more than par
"Double Bogey:" number of strokes is two more than par
"Triple Bogey:" number of strokes is three more than par
"Quadruple Bogey:" number of strokes is four more than par

Just output the message "Oh, not good..." if the number of strokes is more than four over par.

Write a program like this:

CONSOLE INPUT: Two integers, the first of which represents par and the second specifying the number of strokes actually used by the player.

CONSOLE OUTPUT:
Appropriate score name. For example if the par was 4 and the strokes was 6, print "Double Bogey"

Print "Error" if par is not 3, 4, or 5.

NOTE: Using what you have learned lately about Class design, you are expected to create a nicely organized custom class when implementing these specifications.

HINTS:

Use branching, i.e. "if-else" or "match" to write this program.  Documentation of match statement. https://docs.python.org/3/whatsnew/3.10.html

WHAT TO SUBMIT: Your code in the box below.

             

Additional resources for assignment (download file via dropbox):                                                             

  • golfTemplateCode.py  https://www.dropbox.com/scl/fi/vjeu6fhrm1fod0n1dormp/golfTemplateCode.py?rlkey=xgi1010bop3y3pbq7u1zdkn5t&dl=0                       

Step by Step Solution

3.42 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

You can create a GolfScore class to handle this task Heres a Python program that impleme... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistics For Business & Economics

Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams, Jeffrey D. Camm, James J. Cochran

14th Edition

1337901067, 978-1337901062

More Books

Students also viewed these Programming questions

Question

7. What is a causal research design? What is its purpose?

Answered: 1 week ago

Question

Contrast efficiency and utilization.

Answered: 1 week ago

Question

How can long-term capacity requirements be determined?

Answered: 1 week ago