Python Function Overloading in Class For Area || Polymorphism || Python

In this we are going to see a program on Python Function Overloading in Class For Area in Python Programming Language.


class Area:
    def area(self, x=None, y=None):
        if x != None and y != None:
            print(f"Area of a Rectangle is {x*y}")
        elif x != None and y == None:
            print(f"Area of a Square is {x*x}")
        else:
            print("No Input")


a = Area()
a.area(5, 8)
a.area(5)
a.area()

# Coded By Dhiraj Shelke

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post