Define a class named Shape and its subclass(Square/ Circle). The subclass has an init function which takes an argument (Lenght/redious). Both classes should have methods to calculate area and volume of a given shape.
class Shape:
pass
class Square(Shape):
def
__init__(self,l2):
self.l=l2
def
SArea(self):
a=self.l * self.l
print("Area of Square:", a)
def
SPerimeter(self):
p=4 * self.l
print("Perimeter of Square:",p)
class Circle(Shape):
def
__init__(self,r2):
self.r=r2
def
CArea(self):
a=3.14 * self.r * self.r
print("Area of Circle:", a)
def SCircumference(self):
c=2 * 3.14 * self.r
print("Circumference of Circle:",c)
l1=int(input("Enter Length of Square: "))
x=Square(l1)
x.SArea()
x.SPerimeter()
r1=int(input("Enter Radius of Circle: "))
x=Circle(r1)
x.CArea()
x.SCircumference()