Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from graphics import *
- x1 = 20
- y1 = 30
- x2 = 180
- y2 = 165
- w = GraphWin("Graphics Window", 400, 400)
- line = Line(Point(x1, y1), Point(x2, y2))
- line.draw(w)
- dx = x2 - x1
- dy = y2 - y1
- #slope = dx/dy # if dy is zero then it gives ERROR
- length = (dx**2 + dy**2)**0.5
- print(length)
- txt = Text(Point(200, 200), str(length))
- txt.draw(w)
- p = Point(50, 60)
- p.getX()
- p.getY()
- w.getMouse() # wait on mouse click
- w.close() # close window
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement