Source Code
#Rect.py
class Rectangle:
def __init__(self):
print("Rectangle")
def Area(self, length, width):
self.l=length
self.w=width
print("Area of Rectangle is : ", self.l*self.w)
#Sq.py
class Square:
def __init__(self):
print("Square")
def Area(self, side):
self.a=side
print("Area of square is : ", self.a*self.a)
#main.py
from Shape import Rect
from Shape import Sq
r=Rect.Rectangle( ) #Create an object r for Rectangle class
r.Area(10,20) # Call the module Area( ) of Rectangle class by passing argument
s=Sq.Square( ) #Create an object s for Square class
s.Area(10) # Call the module Area( ) of Square class by passing argument
No comments:
Post a Comment