Skip to content

Instantly share code, notes, and snippets.

@rdcoder33
Created December 28, 2018 04:50
Show Gist options
  • Save rdcoder33/044cb7bee6ff0870f42c1bd1982cfc72 to your computer and use it in GitHub Desktop.
Save rdcoder33/044cb7bee6ff0870f42c1bd1982cfc72 to your computer and use it in GitHub Desktop.
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
pass
@abstractmethod
def perimeter(self):
pass
class Square(Shape):
def __init__(self, side):
self.side = side
def area(self):
return self.side ** 2
def perimeter(self):
return self.side * 4
square_obj = Square(5)
print(square_obj.area())
print(square_obj.perimeter())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment