Write a python class Shape and Sub class Square:


Topic: Write a python class Shape and Sub class Square:

Solution

class Shape():
def __init__(self,length = 0):
self.length = length
def Area(self):
print("Area of Shape is 0")
class Square (Shape):
def __init__(self,length = 0):
self.length = length
def Area(self):
self.area = self.length*self.length
print("Area of a Square is: {}".format(self.area))
s1 = Square(2)
s1.Area()



List all Python Programs