You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromabcimportABC, abstractclassmethod# abc - abstract base class & python don't provide any abstract class there is a built-in modules which is in this line
3
+
4
+
5
+
classShape(ABC):
6
+
@abstractclassmethod# its decorator
7
+
defarea(self): pass# empty method
8
+
9
+
#@abstractclassmethod # abstractmethod is a mthd which must be implemented in subclass
10
+
defperimeter(self):pass
11
+
12
+
classSquare(Shape):
13
+
def__init__(self, side):
14
+
self.__side=side
15
+
defarea(self):
16
+
returnself.__side*self.__side
17
+
defperimeter(self):
18
+
return4*self.__side
19
+
20
+
21
+
square=Square(5) # it can't be intantiated bcoz its abstract class
0 commit comments