Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
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
Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0  1   2    3
Write a program that draws the following graphic consisting of 50 circles with randomly generated radii between 0 and 100 and centers randomly located within the 200 by 200 stage. Hint: use a for loop and add each circle as an anonymous circle into a pane. You will need to set the fill color of each circle to TRANSPARENT and the stroke to BLACK.
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