In this we are going to see a program about Python Abstract Base Class Performing Data Abstraction in Python Programming Language.
from abc import ABC, abstractmethod
class Fruit(ABC):
@abstractmethod
def colour(self):
pass
class Apple(Fruit):
def colour(self):
print("Red Coloured fruit")
class Mango(Fruit):
def colour(self):
print("Yellow coloured fruit")
class Peach(Fruit):
def colour(self):
print("Pink coloured fruit")
class Kiwi(Fruit):
def colour(self):
print("Brown coloured fruit")
a = Apple()
a.colour()
m = Mango()
m.colour()
p = Peach()
p.colour()
k = Kiwi()
k.colour()
# Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP