Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this program, five turtles shaped like balls will randomly move within the window. Start with your previous Turtle Bounce solution and change as follows.

For this program, five turtles shaped like balls will randomly move within the window. Start with your previous Turtle Bounce solution and change as follows.

Write a program called balls_bounce.py.

  1. Name your file exactly balls_bounce.py
  2. Add the standard header: name, date, brief description
  3. Import the turtle and random modules.
  4. Set up a window 500 x 500.
  5. Apply a title, Balls Bounce, to your window.
  6. Create a function to create a turtle object. The function should return a turtle as follows:
    • shaped like a circle (ball).
    • positioned in the window.
    • Colored red.
    • pen should be up.
    • a random direction, each turtle a new random direction.
  7. Use a loop to create a list of five balls (turtle objects). In each iteration call the function that creates the ball and then add the ball to a list.
  8. Use a while True loop to simulate animation.
  9. Within the while True loop, nest a loop that loops over the items (turtles) in the list
    • Move the item (a turtle) forward 5 pixels per movement.
    • Use the function written in turtle_bounce that:
      1. Checks to see if the turtle (ball) has passed the edge of the window.
      2. If so, moves it backward and changes its direction.
    • Repeat for all items in the list
  10. Add line comments for each logical section of your code.

Upload only your balls_bounce.py to this assignment. A screenshot is not necessary.

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

What were the results?

Answered: 1 week ago

Question

Distinguish between filtering and interpreting. (Objective 2)

Answered: 1 week ago