class Rectangle:
"""created a class Rectangles, assigning values"""
number_of_instances = 0
print_symbol = "#"
def __init__(self, width=0, height=0):
self.height = height
self.width = width
Rectangle.number_of_instances += 1
@property
def width(self):
return self.__width
@width.setter
def width(self, value):
if not isinstance(value, int):
raise TypeError("width must be an integer")
elif value < 0:
raise ValueError("width must be >= 0")
self.__width = value
@property
def height(self):
return self.__height
@height.setter
def height(self, value):
if not isinstance(value, int):
raise TypeError("height must be an integer")
elif value < 0:
raise ValueError("height must be >= 0")
self.__height = value
def area(self):
return self.__height * self.__width
def perimeter(self):
if self.__height == 0 or self.__width == 0:
return 0
return (self.__height + self.__width) * 2
def __str__(self):
if self.__width == 0 or self.__height == 0:
return ''
for z in range(self.height - 1):
print(str(self.print_symbol) * self.__width)
return str(self.print_symbol * self.__width)
def __repr__(self):
return "Rectangle({}, {})".format(self.__width, self.__height)
def __del__(self):
print("Bye rectangle...")
Rectangle.number_of_instances -= 1
@staticmethod
def bigger_or_equal(rect_1, rect_2):
if not isinstance(rect_2, Rectangle):
raise TypeError("rect_2 must be an instance of Rectangle")
elif not isinstance(rect_1, Rectangle):
raise TypeError("rect_1 must be an instance of Rectangle")
elif rect_1 == rect_2:
return rect_1
elif rect_1 > rect_2:
return rect_1
elif rect_2 > rect_1:
return rect_2
tried to compare but got an error...
TypeError: '>' not supported between instances of 'Rectangle' and 'Rectangle'
should I call any of the functions?