Data Abstraction with Constructors using Inheritance in Python - 2 || Data Abstraction || Python

In this we are going to see a program on Data Abstraction with Constructors using Inheritance in Python - Type 2 in Python Programming Language.


class Shape:
    def area(self):
        pass


class Rect(Shape):
    def __init__(self, l, b):
        self.l = l
        self.b = b

    def area(self):
        print(self.l*self.b)


class Circle(Shape):
    def __init__(self, r):
        self.r = r

    def area(self):
        print(self.r**2*3.142)


r = Rect(5, 6)
r.area()

c = Circle(5)
c.area()

# Coded by Saahil

#ENJOY CODING

Post a Comment

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

Previous Post Next Post