def main(): p1 = point(10) p2 = point(10, 20) print(p1) print(p2) print(p1 + p2) print(p1 + (20, 30))
def main(): point1 = point() point2 = point() point1.x = 5 point1.y = 10 point2.x = 10 point2.y = 15 print(distance_between_points(point1, point2))
def main(): r = rectangle() r.width = 100.0 r.height = 200.0 r.corner = point() r.corner.x = 50.0 r.corner.y = 50.0 print("Center coordinates of rectangle:", find_center(r)) r1 = move_rectangle(r, 10, 5) print("Existing Rectangle new position corner coordinates:", r1.corner.x, r1.corner.y) r2 = move_rectangle1(r, 100, 150) print("New Rectangle corner coordinates:", r2.corner.x, r2.corner.y) turtle.mainloop()
def add_points_tuple(self, other): """Adds a tuple.""" return point(self.x + other[0], self.y + other[1])
def add_points(self, other): """Adds a point.""" return point(self.x + other.x, self.y + other.x)
def __add__(self, other): """Adds a point.""" return point(self.x + other.x, self.y + other.y)