Tell us what’s happening:
I have a following error message, when running the code:
“python main.py
Traceback (most recent call last):
File “main.py”, line 6, in
rect = shape_calculator.Rectangle(5, 10)
TypeError: Rectangle() takes no arguments
exit status 1”
What am I missing?
Your code so far
class Rectangle:
def __innit__(self, width, height):
self.width = width
self.height = height
def __str__(self):
return f'Rectangle(width={self.width}, heigth={self.height}'
def set_width(self, width):
self.width = width
def set_heigth(self_height):
self.heigth = heigth
def get_area(self):
return self.width * self.height
def get_perimiter(self):
return 2 * self.width + 2 * self.heigth
def get_diagonal(self):
return ((self.width ** 2 + self.heigth ** 2) ** .5)
def get_picture(self):
if self.width > 50 or self.heigth > 50:
return "Too big picture"
string = (("*" * self.width) + "\n") * self.heigth
def get_picture(self, width, height):
if self.width > 50 or self.height > 50:
return "Too big for picture"
string = (("*" * self.width) + "\n") * self.height
return string
def get_amount_inside(self, shape):
return int(self.get_area() / self.get_area())
class Square(Rectangle):
def innit(self, side):
self.width = side
self.height = side
def str(self):
return f’Square(side={self.width})’
def set_side(self):
self.width = side
self.heigth = side
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15
Challenge: Scientific Computing with Python Projects - Polygon Area Calculator
Link to the challenge: