Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python Abstract Classes Example
from abc import ABC, abstractmethod
class Shape(ABC):
def area(self): pass
def perimeter(self): pass
class Square(Shape):
def __init__(self, side):
self.__side = side
def area(self):
return self.__side * self.__side
def perimeter(self):
return 4 * self.__side
square = Square(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment