import math
class TwoDObject:
def __init__(self,x=0,y=0):
self.x = x
self.y = y
def area(self):
return 0
def move(self,xchange=0,ychange=0):
self.x = self.x + xchange
self.y = self.y + ychange
class Circle(TwoDObject):
def __init__(self,radius:float=1,**kwargs):
self.radius = radius
super().__init__(**kwargs)
def area(self):
return(self.radius*self.radius*math.pi)
def size_change(self,percent:float):
self.radius = self.radius * (percent/100)
class Sector(Circle):
def __init__(self,angle:float=180,**kwargs):
self.angle = angle
super().__init__(**kwargs)
def area(self):
return super().area() * self.angle/360
class Rectangle(TwoDObject):
def __init__(self,height:float=1,width:float=1,**kwargs):
self.width = width
self.height = height
super().__init__(**kwargs)
def area(self):
return self.width * self.height
def size_change(self,percent:float):
self.width = self.width * (percent/100)
self.height = self.height * (percent/100)
if __name__ == "__main__":
c = Circle(5,11,22)
r = Rectangle(100,100,20,20)
print(c.x,c.y)
What I have tried:
the code throws an error that there are more arguments for Circle objject,but actually the circle class take 3 parameters but in fact exactly 3 arguments to the c objcect are given
the type error :
Traceback (most recent call last):
File "2tsal.py", line 46, in <module>
c = Circle(5,11,22)
TypeError: __init__() takes from 1 to 2 positional arguments but 4 were given