Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 17PE
Program Plan Intro
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()”
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that displays an inchworm on the left-hand side of the screen,
facing right. Then slowly move him across the screen, until he disappears off the
right-hand side. You may wish to do this in a loop so that after disappearing to the
right, the worm appears again on the left. The diagram below shows how he may
look at various points on the screen.
00
00
000 00
00
00
-000000000
-0000 0000
-000
000
-0000 0000
-000000000
Please do it C++, and show the output as well,
thank you
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 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.
Chapter 7 Solutions
Python Programming: An Introduction to Computer Science
Ch. 7 - Prob. 1TFCh. 7 - Prob. 2TFCh. 7 - Prob. 3TFCh. 7 - Prob. 4TFCh. 7 - Prob. 5TFCh. 7 - Prob. 6TFCh. 7 - Prob. 7TFCh. 7 - Prob. 8TFCh. 7 - Prob. 9TFCh. 7 - Prob. 10TF
Ch. 7 - Prob. 1MCCh. 7 - Prob. 2MCCh. 7 - Prob. 3MCCh. 7 - Prob. 4MCCh. 7 - Prob. 5MCCh. 7 - Prob. 6MCCh. 7 - Prob. 7MCCh. 7 - Prob. 8MCCh. 7 - Prob. 9MCCh. 7 - Prob. 10MCCh. 7 - Prob. 1DCh. 7 - Prob. 2DCh. 7 - Prob. 3DCh. 7 - Prob. 1PECh. 7 - Prob. 2PECh. 7 - Prob. 3PECh. 7 - Prob. 4PECh. 7 - Prob. 5PECh. 7 - Prob. 6PECh. 7 - Prob. 7PECh. 7 - Prob. 8PECh. 7 - Prob. 9PECh. 7 - Prob. 10PECh. 7 - Prob. 11PECh. 7 - Prob. 12PECh. 7 - Prob. 13PECh. 7 - Prob. 14PECh. 7 - Prob. 15PECh. 7 - Prob. 16PECh. 7 - Prob. 17PECh. 7 - Prob. 18PE
Knowledge Booster
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
- 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.arrow_forwardThis is a java assignment. I have attached it in the image file.arrow_forwardA square is divided into four smaller regions as shown below in (a). If you throw a dart into the square 1,000,000 times, what is the probability for a dart to fall into an odd-numbered region? Write a program to simulate the process and display the result.arrow_forward
- Write a program that asks a user to input the height of triangle and draw a triangle that has the following pattern. Use nested loops for this problem. If the user enter height as 4 Then the triangle output is 1 1 2 1 2 3 1 2 3 4 We make the following assumptions • There is no space between the margin and first number in each row • There could be a space after the last number on every line • There is pne space between numbers on every line • There maybe a newline at the end of last line There is one test-case to check your code, there are two hidden testcases that tests correctness of your code 376584 2469arrow_forwardWrite a program in Python, in which the user can enter any number of positive and negative integer values, and then we display the total number of positive values entered and the total number of negative values entered. We are going to use a sentinel value (also known as a flag value) to control the loop. If the user wants to quit counting up positive and negative numbers, the user will enter a (q). The first line should print out a title that says something like “Practice 4: Counting the number of positive and negative values entered by the user”.arrow_forwardDevelop a solution that will calculate the average temperature, given a set of temperatures. The number of temperatures may differ from time to time. (Use a trip values to stop the processing of the loop.) Test the solution with the following 10 temperatures. 78 90 85 80 87 83 75 90 86 70arrow_forward
- Write python code A skilled shooter tries to hit an apple with the Tomahawk arrow. At the same time, as he fires, the apple falls freely. If the velocity of the arrow is m/s, heights for both (apple and tomahawk) are m and horizontal distance between them is 400m, calculate the time when the arrow will hit the apple and visualize it as a simulation. Create an arrow and apple as defined.. Define a loop to update the speeds and positions of both (for both apple and arrow) including the effect of gravity. Plot the graph (Position : s Time).arrow_forwardWrite a program that asks the user for a positive integer value and that uses a loop to validate the input. The program should then use a second loop to compute the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, … 50.arrow_forwardWrite a program that displays a random coordinate in a rectangle.The rectangle is centred at (0, 0) with width 50 and height 150.arrow_forward
- Factorial of a number n is denoted as n! And the value of n! Is: 1*2*3... (n-1)*n. Create Java Program to find factorial of a positive integer number using the following Loops: a. for Loop b. while loop Valid input is less than or equal to 15 (Input <= 15) only, otherwise the input is Invalid. Please see the attached image for the Output format. Please don't answer my question if you don't read the instructions carefully, this is my last question so please cooperate.arrow_forwardHow often do the following loops execute? Assume that i is not changed in theloop body.a. for (int i = 1; i <= 10; i++) ...b. for (int i = 0; i < 10; i++) ...c. for (int i = 10; i > 0; i--) ...d. for (int i = -10; i <= 10; i++) ... e. for (int i = 10; i >= 0; i++) ...f. for (int i = -10; i <= 10; i = i + 2) ... g. for (int i = -10; i <= 10; i = i + 3arrow_forwardLoops to be used in Processingarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
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