class Rectangle: """ A class to represent a rectangle. Attributes ---------- x1 : (int) bottom left x-coordinate y1: (int) bottom left y-coordinate x2 : (int) top right x-coordinate y2: (int) top right y-coordinate Methods ------- area(): (int) returns the area of the rectangle """ def __init__(self, x1, y1, x2, y2): """ Creates a two-dimensional rectangle and sets its bottom left and top right coordinates :param x1: (int) bottom left x-coordinate :param y1: (int) bottom left y-coordinate :param x2: (int) top right x-coordinate :param y2: (int) top right y-coordinate """ self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 def area(self): """ Returns the area of the rectangle :return: (int) the area of the rectangle """ width = abs(self.x2 - self.x1) height = abs(self.y2 - self.y1) return width * height def __str__(self): """ Returns string representation of rectangle :return: (str) "The four coordinates of the rectangle are: x1: ... and its area is: (area)" """ return "The four coordinates of the rectangle are: x1: " + str(self.x1) +\ " , y1: " + str(self.y1) + " , x2: " + str(self.x2) + " , y2: " + \ str(self.y2) + " and its area is: " + str(self.area()) + " units." def main(): rect = Rectangle(0, 0, 10, 20) print(rect) if __name__ == "__main__": main()