from abc import ABC,abstractmethod class polygon(ABC): @abstractmethod def no_of_sides(self): pass class triangle(polygon): def no_of_sides(self): print('I have 3 sides') class pentagon(polygon): def no_of_sides(self): print('I have 5 sides') class hexagon(polygon): def no_of_sides(self): print('I have 6 sides') class quadrilateral(polygon): def no_of_sides(self): print('I have 4 sides') t=triangle() t.no_of_sides() p=pentagon() p.no_of_sides() h=hexagon() h.no_of_sides() q=quadrilateral() q.no_of_sides()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter