class Rectangle: """ An alternative class to represent a rectangle. Attributes ---------- x : (int) bottom-left x-coordinate y: (int) bottom-left y-coordinate width : (int) width height: (int) height 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 coordinates, width, and height :param x1: (int) first x-coordinate :param y1: (int) first y-coordinate :param x2: (int) second x-coordinate :param y2: (int) second y-coordinate """ # find the bottom-left corner if x2 < x1: x1, x2 = x2, x1 if y2 < y1: y1, y2 = y2, y1 self.x = x1 self.y = y1 self.width = x2 - x1 self.height = y2 - y1 def area(self): """ Returns the area of the rectangle :return: (int) the area of the rectangle """ return self.width * self.height def __str__(self): """ Returns string representation of rectangle :return: (str) "The bottom left coordinates of the rectangle are: x: , its width is: , its height is: ... and its area is: (area)" """ return "The bottom left coordinates of the rectangle are: x: " + str(self.x) + \ " and y: " + str(self.y) + " , its width: " + str(self.width) + " , height: " + \ str(self.height) + " and its area is: " + str(self.area()) + " units." def main(): rect = Rectangle(0, 0, 10, 20) print(rect) if __name__ == "__main__": main()