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

React Installation with Vite and Tailwind css (Steps to Installation)

Insert Data In mongoDb

Class methods as an alternative Constructor