Modify Example 1.5 so that the turtle bounces against all four sides. Start the
ID: 3744495 • Letter: M
Question
Modify Example 1.5 so that the turtle bounces against all four sides. Start the turtle moving at an angle. Hint: bounce in the x direction by changing the heading to 180 -heading(); in the y direction, set it to -heading().
1 # bounce . P 2 # Bounce the turtle. 3 4 from turtle import :* def move (distance): 6 7 8 9 10 """Move forward, reversing direction at right side. """ forward(distance) if xcor 320: setheading(180) 12 def main): 13 14 15 16 17 18 19 20 maln() shape ("circle") penup() speed(0) for_in range(100): move (10) exitonclick() Example 1.5 Bouncing turtle.Explanation / Answer
please provide turtle.py as the functions were taken from there
as was not able to understand the definition of setheading() as it is also said to be set to y-coordinates
thankyou
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.