Tell us what’s happening:
Went through each invalid test and none of them make any sense since they all come back on the terminal correct. Please help
Your code so far
import math
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
@property
def width(self):
return self._width
@width.setter
def width(self, new_width):
self._width = new_width
@property
def height(self):
return self._height
@height.setter
def height(self, new_height):
self._height = new_height
def get_area(self):
return self.width * self.height
def get_perimeter(self):
return 2 * (self.width + self.height)
def get_diagonal(self):
return math.sqrt(self.width*self.width + self.height*self.height)
def get_picture(self):
result = ""
if self.width > 50 or self.height > 50:
return 'Too big for picture.'
for i in range(self.height):
result += '*' * self.width + '\n'
return result
def get_amount_inside(self, shape):
return (self.width // shape.width) * (self.height // shape.height)
def __str__(self):
return f"Rectangle(width={self.width}, height={self.height})"
class Square(Rectangle):
def __init__(self, length):
super().__init__(length, length)
def set_width(self, side):
self.width = side
self.height = side
def set_height(self, side):
self.width = side
self.height = side
def set_side(self, side):
self.width = side
self.height = side
def __str__(self):
return f'Square(side={self.width})'
rect = Rectangle(50, 7)
print(rect.get_picture())
rect2 = Rectangle(15, 10)
print(rect2.get_amount_inside(Square(5)))
rect2.width = 10
print(rect2)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Challenge Information:
Build a Polygon Area Calculator - Build a Polygon Area Calculator