Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Videos

Question
Book Icon
Chapter 7, Problem 17PE
Program Plan Intro

Program to displays a circle bouncing around the window

Program plan:

  • Import the required packages
  • In the “main()” function,
    • Create the object of “GraphWin()”.
    • Set the coordinates by calling the function “setCoords()”
    • Create an object named “shape” and store the points
    • The outline of the circle is set to “red” color.
    • The circle is filled with “red” color.
    • Draw the circle with the use of function “draw()”.
    • Declare the required variables.
    • Initialize a for loop to get the value of the points.
      • Store the center of the circle in “c”.
      • If the x-value is greater than 80 then
        • Assign the value of “dx” as “-1”.
      • If the x-value is less than -80
        • Assign the value of “dx” as “1”.
      • If the y-value is greater than 80 then
        • Assign the value of “dy” as “-1”.
      • If the y-value is less than -80
        • Assign the value of “dy” as “1”.
      • Use the function “sleep()” to slow the program.
      • Move the circle to the resulting point.
  • Call the function named “main()”

Blurred answer
Students have asked these similar questions
Write a program that will print asterisks in the shape of a diamond. The height of the diamond will depend on the value entered by the user. That value MUST be greater than 0, and it MUST be odd. To make sure that the value is correct, you will validate the value once the user has entered it using a validation loop. Then you will print out a diamond in the pattern demonstrated in the sample execution. Remember that the height will vary based on the user input.
A square is divided into four smaller regions as shown in (a). If you throw a dart into the square one million times, what is the probability for the dart to fall into an odd-numbered region? Write a program to simulate the process and display the result.
Write a program that draws a graphic consisting of 50 rectangles with randomly generated sides and 75 located randomly within a 300 by 300 stage. Hint: use a for loop and add each rectangle anonymous rectangle into a pane You will need to set the fill color of each rectangle to TRANSE the stroke to BLACK.
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY