Question: Write a program called balls_bounce.py . Name your file exactly balls_bounce.py Add the standard header: name, date, brief description Import the turtle and random modules.
Write a program called balls_bounce.py.
- Name your file exactly balls_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, Balls Bounce, to your window.
- 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.
- 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.
- Use a while True loop to simulate animation.
- 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:
- Checks to see if the turtle (ball) has passed the edge of the window.
- If so, moves it backward and changes its direction.
- Repeat for all items in the list
- Add line comments for each logical section of your code.
Upload only your balls_bounce.py to this assignment. A screenshot is not necessary.
Rubric
Balls Bounce Rubric
Balls Bounce Rubric
Criteria Ratings Pts This criterion is linked to a Learning OutcomeFilename is balls_bounce.py 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeProgram Header as specified 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeMeaningful line comments for each logical section of code 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeWhitespace (blank lines) added to separate logical sections of code 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeWindow 500x500 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeWindow title is Balls Bounce 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeFunction written to create a turtle object as specified in turtle_bounce assignment, shaped like a ball (circle), and positioned the window, with a random direction between 0 and 360 degrees. Each ball moves its own direction until it has passed the edge of the window. 3.0 pts Full Marks 0.0 pts No Marks 3.0 pts This criterion is linked to a Learning OutcomeLoop uses function to create a list of 5 Turtle objects (balls) 3.0 pts Full Marks 0.0 pts No Marks 3.0 pts This criterion is linked to a Learning OutcomeThere are no lines created by the drawing. 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning Outcomewhile True: loop used for animation 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeNested loop loops over the items (balls) in the list 3.0 pts Full Marks 0.0 pts No Marks 3.0 pts This criterion is linked to a Learning OutcomeIn the nested loop each ball moves 5 pixels. 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeIn the nested loop, use the function written in turtle_bounce to determine if a ball has crossed the boundary, reposition the ball and change heading (a new random direction from 0 to 360 degrees) as necessary. 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeRepeat ball movements until the user closes the turtle window. 1.0 pts Full Marks 0.0 pts No Marks 1.0 pts This criterion is linked to a Learning OutcomeSyntax and runtime errors deductions 0.0 pts Full Marks 0.0 pts No Marks 0.0 pts Total Points: 20.0PreviousNext
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
