Question: Name your file exactly turtle_bounce.py Add the standard header: name, date, brief description Import the turtle and random modules. Set up a window 500 x
- Name your file exactly turtle_bounce.py
- Add the standard header: name, date, brief description
- Import the turtle and random modules.
- Set up a window 500 x 500.
- Apply a title, Turtle Bounce, to your window.
- Create one turtle object, shaped like a turtle, and position it in the window.
- Turtle's pen should be up.
- Move the turtle forward, 5 pixels per movement.
- Turtle starts in a random direction.
- Turtle stays in the same direction until the turtle has passed the edge of the window.
- Each time the turtle moves:
- Check to see if the turtle has passed the edge of the window.
- If the turtle is outside the window, move it back on to the window, approximately where it left. Move it backward (forward -5 pixels).
- When the turtle returns to the window, change its direction, to a new random direction.
- The program must contain a while loop, one or more if statements, and a function. Use a function for step 11.
- Add line comments for each logical section of your code.
Hints: Use one or more of the following expressions, statements, methods, and functions.
- SIZE=500
- SIZE/2
- setup(,)
- title()
- Turtle(), myTurtle.shape(), myTurtle.penup(), myTurtle.forward(), myTurtle.setheading() where myTurtle is the name of the turtle object variable. You can name the turtle as you please (e.g. john)
- while True:
- random.randrange(360)
- x, y = myTurtle.position()
- abs(x)
- abs(y)
Save and run your program.
Before it moves it might look like this:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
