Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Python to be used in a dart game which calculates whether a thrown dart hits the dart board. A dart will

image text in transcribed

image text in transcribed

image text in transcribed

Write a program in Python to be used in a dart game which calculates whether a thrown dart hits the dart board. A dart will be shown with x and y coordinates represented as a tuple (X.X). Randomly, create 10 tuples for 10 darts thrown and store them in a list. The program should show if the dart hits the board or not as true or false. The radius of the dart board is accepted as 11. (radius=11/center=(0,0)) The distance between the dart and the center of the board is going to be calculated, according to the formula given below: distance = (x2-x2)+6012-722) Yaxis (0,01 ang xaxis Then, determine whether the dart hits the board and output the following: If distance > radius, "Outside of the dart board!" and Result: False If distance 10 points Distance between 4-7 (Red Ring) => 5 points Distance between 8-11 (Blue Ring) => 3 points Distance between 12-15 (Black Ring) => 2 points Distance between 16 - 19 (White Ring) => 1 point Distance above 19 (Off Target) => 0 point Finally, output your total score. a) Write your program using loops. Sample Output: AM** Playing Dart Game ** Hit Point is: (1, 5) Center is: (@, ) The distance is: 5.8998195135927845 Result: True Hit the board! Score: 5 Hit Point is: (2. 6) Center is: (8,8) The distance is: 6.324555328336759 Result: True Hit the board! Score: 5 Hit Point is: (3,9) Center is: (@, e) The distance is: 9.486832988565138 Result: True Hit the board! Score: 3 b) Modify your program by using map function, no loops. Sample Output: Hit Point is: (6, 3) Center is: (0, 0) The distance is: 6.708203932499369 Result: True Hit the board! Score: 5 Hit Point is: (7, 2) Center is: (, ) The distance is: 7.280109889280518 Result: True Hit the board! ! Score: 3 Hit Point is: (8, 8) Center is: (@, e) The distance is: 11.313708498984761 Result: False Outside of the dart board

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

What is Aufbau's rule explain with example?

Answered: 1 week ago

Question

=+ Are there additional forms of employee representation?

Answered: 1 week ago

Question

=+What is the nature of their impact?

Answered: 1 week ago

Question

=+Is it possible to operate union-free?

Answered: 1 week ago