class Rectangle:
def init(self, width, height):
self.width = width
self.height = height
# Setter function (width)
def set_width(self, width):
self.width = width
# Setter function (height)
def set_height(self, height):
self.height = height
#return the areaof the shape
def get_area(self):
return self.width * self.height
#Get the perimeterof the shape
def get_perimeter(self):
return 2 * self.width + 2 * self.height
#Get diagonal
def get_diagonal(self):
return ((self.width ** 2 + self.height ** 2)**.5)
#Display a picture
def get_picture(self):
if self.height > 50 or self.width > 50:
return "Too big for picture."
for i in range(int(self.height)):
x = (self.width) * ("*")
y = print(x)
return y
#How many times to fir into get_picture
def get_amount_inside(self, obj):
return (self.width // obj.width) * (self.height // obj.height)
def __str__(self) -> str:
return ("Rectangle(width={}, height={})".format(self.width, self.height))
class Square(Rectangle):
def init(self, side):
self.height = side
self.width = side
# Setter Function (side)
def set_side(self, side):
self.height = side
self.width = side
# Setter function (width)
def set_width(self, side):
self.width = side
# Setter function (height)
def set_height(self, side):
self.height = side
#String output for the square
def __str__(self):
return "Square(side={})".format(self.width)