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 8PE
Program Plan Intro

Program to draw a line segment

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.
    • Using the method Line(), draw a line with midpoint in cyan color.
    • Compute the length and slope of the line using the formula given in textbook.
    • Print the length and slope of line.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
python
In PYTHON Using one of the loop construct draw:- Ten dashed Vertical lines- Each line of length 150 units (or pixels)- All lines aligned at the same top horizontal margin - Lines 10 units apart each other Note- Set the length of solid segment to 10 units- Set the length of the non-visible segment to 5 units Assumption- Use of Turtle library
In PYTHON Using one of the loop construct draw:- Ten dashed Horizontal lines- Each line of length 150 units (or pixels)- All lines aligned at the same left vertical margin- Lines 10 units apart each other Note- Set the length of solid segment to 10 units- Set the length of the non-visible segment to 5 units Assumption- Use of Turtle library
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Expressions in C++ | C++ tutorial for beginners; Author: Tutorial Mart;https://www.youtube.com/watch?v=XHbsZGpmRc8;License: Standard YouTube License, CC-BY
expression in python # python expressions; Author: Abhishek Tripathi;https://www.youtube.com/watch?v=Cc-kJGRjH6k;License: Standard Youtube License