Abstract Method Example

from abc import ABC,abstractmethod

class Shape(ABC):
@abstractmethod
def printAria(self): # ab sabhi cls ko printAria funtion apne andr define kr na hi hoga
return 0

class rectangle(Shape):
type="rectangle"
side=4
def __init__(self):
self.lenght=5
self.wirdth=6

# def printAria(self):
# return self.lenght*self.wirdth


rect=rectangle()
print(rect.printAria())

Comments

Popular posts from this blog

Healthy Programmmer PROJECT

Difference Between Procedural and Non-procedural Language

Dictionary Practice Question