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

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 4, Problem 9PE
Program Plan Intro

Program to draw a rectangle

Program plan:

  • Import the math package.
  • Import the required graphics package.
  • Define the main method.
    • Using the object GraphWin(), to display the graphics window.
    • Using the method setCoords(), set the size of the graphics window.
    • Prompt the user for 2 mouse clicks.
    • Store coordinates in variables x1, x2, y1 and y2.
    • Calculate the area and perimeter of the rectangle using the given formula.
    • Using the method Rectangle(), draw a rectangle in the graphics window.
    • Print the area and perimeter of the rectangle.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
Money Counting Algorithm: Write a program that shows how much the 25 cents, 50 cents and 1 TL coins you put on paper are worth using the size and color information. The algorithm is entirely up to you. Explain the algorithm you developed, add code and images. b) Heads and Tails Detection Algorithm: Write the program that shows whether the coin placed on the paper is heads or tails. Developing the algorithm is entirely up to you. This algorithm should work in three currencies. (If you find a suitable code, etc. somewhere, it is a direct copy. Your codes should be in accordance with the lectures. Put explanations about what you are doing).
The area of a rectangle is the rectangle’s length times its width. Write a program that asks for the length and width of two rectangles. The program should then tell the user which rectangle has the greater area, or if the areas are the same.
Areas of Rectangles The area of a rectangle is the rectangle's length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same.
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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY