19. Turtle Graphics: Hit the Target Modification Enhance the hit_the_target.py program that you saw in Program 3-9 so that, when the projectile misses the target, it displays hints to the user indicating whether the angle and/or the force value should be increased or decreased. For example, the program should display messages such as 'Try a greater angle' and 'Use less force. '
19. Turtle Graphics: Hit the Target Modification Enhance the hit_the_target.py program that you saw in Program 3-9 so that, when the projectile misses the target, it displays hints to the user indicating whether the angle and/or the force value should be increased or decreased. For example, the program should display messages such as 'Try a greater angle' and 'Use less force. '
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Concept explainers
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Question
Design and write a Python program for exercise #19:
Please label your steps with comments (#) on your program

Transcribed Image Text:1
2
3
4
# Hit the Target Game
import turtle
# Named constants
5
SCREEN WIDTH = 600
8
6 SCREEN HEIGHT = 600
7 TARGET LLEFT_X = 100
TARGET LLEFT_Y = 250
= 250
TARGET WIDTH = 25
10 FORCE FACTOR = 30
11 PROJECTILE_SPEED = 1
NORTH = 90
12
13
SOUTH = 270
14 EAST 0
15 WEST 180
16
9
17 # Setup the window.
18 turtle.setup (SCREEN_WIDTH, SCREEN_HEIGHT)
19
20 # Draw the target.
21 turtle.hideturtle()
22 turtle.speed (0)
23 turtle.penup()
24 turtle.goto (TARGET_LLEFT_X, TARGET_LLEFT_Y)
25 turtle.pendown ()
26 turtle.setheading (EAST)
27 turtle. forward (TARGET_WIDTH)
turtle.setheading (NORTH)
28
29 turtle.forward (TARGET_WIDTH)
30 turtle.setheading (WEST)
31 turtle.forward (TARGET_WIDTH)
32 turtle.setheading (SOUTH)
33 turtle. forward (TARGET_WIDTH)
turtle.penup()
34
35
36
# Center the turtle.
# Screen width
# Screen height
#Target's lower-left X
# Target's lower-left Y
# Width of the target
#Arbitrary force factor
# Projectile's animation speed
#Angle of north direction
# Angle of south direction
# Angle of east direction
# Angle of west direction
37 turtle.goto(0, 0)
38 turtle.setheading (EAST)
turtle.showturtle()
turtle.speed (PROJECTILE SPEED)
39
40
41
42 # Get the angle and force from the user
43 angle float(input("Enter the projectile's angle: "))
44 force float(input ("Enter the launch force (1-10): "))
45
46 # Calculate the distance.
47
distance force FORCE_ FACTOR
48
49 # Set the heading.
50
51
turtle.setheading (angle)
52 # Launch the projectile.
53 turtle.pendown()
54
55
56
# Did it hit the target?
57 if (turtle.xcor () >= TARGET LLEFT_X and
58
59
60
turtle. forward (distance)
turtle.xcor () <= (TARGET_LLEFT_X+ TARGET WIDTH) and
turtle.ycor () >= TARGET_LLEFT_Y and
turtle, ycor () <= (TARGET_LLEFT_Y + TARGET_WIDTH)):
print('Target hit!')
print('You missed the target.')
61
62 else:
63
4

Transcribed Image Text:19. Turtle Graphics: Hit the Target Modification
Enhance the hit_the_target.py program that you saw in Program 3-9 so that, when the projectile
misses the target, it displays hints to the user indicating whether the angle and/or the force value should be
increased or decreased. For example, the program should display messages such as 'Try a greater
angle' and 'Use less force.'
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education