{"id":1712,"date":"2018-06-13T05:48:23","date_gmt":"2018-06-12T22:48:23","guid":{"rendered":"http:\/\/www.booboohome.com\/blogs\/?p=1712"},"modified":"2026-06-12T23:52:11","modified_gmt":"2026-06-12T16:52:11","slug":"python-inheritance","status":"publish","type":"post","link":"https:\/\/www.booboohome.com\/blogs\/2018\/06\/python-inheritance\/","title":{"rendered":"Python &#8211; Inheritance"},"content":{"rendered":"<p><strong>\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(Inheritance)<\/strong><br \/>\n\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e40\u0e14\u0e48\u0e19\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21\u0e41\u0e1a\u0e1a OO(Object-Oriented Programming) \u0e42\u0e14\u0e22\u0e2d\u0e49\u0e32\u0e07\u0e16\u0e36\u0e07\u0e01\u0e32\u0e23\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e25\u0e32\u0e2a\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e43\u0e2b\u0e21\u0e48\u0e41\u0e25\u0e30\u0e14\u0e49\u0e27\u0e22\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e17\u0e35\u0e48\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e42\u0e14\u0e22\u0e44\u0e21\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e41\u0e01\u0e49\u0e44\u0e02\u0e43\u0e14\u0e46 \u0e42\u0e14\u0e22\u0e04\u0e25\u0e32\u0e2a\u0e43\u0e2b\u0e21\u0e48\u0e40\u0e23\u0e35\u0e22\u0e01\u0e27\u0e48\u0e32\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(derived or child class) \u0e41\u0e25\u0e30\u0e04\u0e25\u0e32\u0e2a\u0e17\u0e35\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a\u0e02\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e19\u0e31\u0e49\u0e19\u0e40\u0e23\u0e35\u0e22\u0e01\u0e27\u0e48\u0e32\u0e04\u0e25\u0e32\u0e2a base(\u0e2b\u0e23\u0e37\u0e2d parent)<\/p>\n<pre class=\"prettyprint lang-python\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\r\nclass BaseClass:\r\n     # \u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e02\u0e2d\u0e07 Base Class\r\n\r\nclass DerivedClass(BaseClass):\r\n     # \u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e02\u0e2d\u0e07 Derived Class\r\n<\/pre>\n<p>\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(derived class) \u0e44\u0e14\u0e49\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a \u0e41\u0e25\u0e30\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e43\u0e2b\u0e21\u0e48\u0e25\u0e07\u0e44\u0e1b\u0e44\u0e14\u0e49 \u0e0b\u0e36\u0e48\u0e07\u0e17\u0e33\u0e43\u0e2b\u0e49\u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e04\u0e25\u0e32\u0e2a\u0e43\u0e2b\u0e21\u0e48\u0e42\u0e14\u0e22\u0e01\u0e32\u0e23\u0e19\u0e33\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e40\u0e14\u0e34\u0e21\u0e17\u0e35\u0e48\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e41\u0e25\u0e49\u0e27\u0e21\u0e32\u0e1b\u0e23\u0e31\u0e1a\u0e1b\u0e23\u0e38\u0e07\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e14\u0e49\u0e21\u0e32\u0e01\u0e02\u0e36\u0e49\u0e19<\/p>\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14<br \/>\n\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e43\u0e2b\u0e49 polygon \u0e40\u0e1b\u0e47\u0e19\u0e23\u0e39\u0e1b\u0e1b\u0e34\u0e14\u0e0b\u0e36\u0e48\u0e07\u0e21\u0e35\u0e14\u0e49\u0e32\u0e07 3 \u0e14\u0e49\u0e32\u0e19 \u0e40\u0e23\u0e32\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e04\u0e25\u0e32\u0e2a polygon \u0e44\u0e14\u0e49\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49<\/p>\n<pre class=\"prettyprint lang-python\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\r\nclass Polygon:\r\n    def __init__(self, no_of_sides):\r\n        self.n = no_of_sides\r\n        self.sides = [0 for i in range(no_of_sides)]\r\n\r\n    def inputSides(self):\r\n        self.sides = [float(input(\"Enter side \"+str(i+1)+\" : \")) for i in range(self.n)]\r\n\r\n    def dispSides(self):\r\n        for i in range(self.n):\r\n            print(\"Side\",i+1,\"is\",self.sides[i])\r\n<\/pre>\n<p>\u0e42\u0e14\u0e22\u0e04\u0e25\u0e32\u0e2a\u0e08\u0e30\u0e21\u0e35\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e02\u0e2d\u0e07\u0e41\u0e2d\u0e17\u0e23\u0e34\u0e1a\u0e34\u0e27\u0e17\u0e4c\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e01\u0e47\u0e1a\u0e08\u0e33\u0e19\u0e27\u0e19\u0e02\u0e2d\u0e07\u0e14\u0e49\u0e32\u0e19\u0e42\u0e14\u0e22 n \u0e41\u0e25\u0e30 magnitude \u0e02\u0e2d\u0e07\u0e41\u0e15\u0e48\u0e25\u0e30\u0e14\u0e49\u0e32\u0e19\u0e17\u0e33\u0e01\u0e32\u0e23\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e38\u0e25\u0e43\u0e19\u0e25\u0e34\u0e2a\u0e15\u0e4c\u0e0a\u0e37\u0e48\u0e2d sides <\/p>\n<p>\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 InputSides() \u0e40\u0e23\u0e32\u0e40\u0e2d\u0e32\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 magnitude \u0e02\u0e2d\u0e07\u0e41\u0e15\u0e48\u0e25\u0e30\u0e14\u0e49\u0e32\u0e19\u0e41\u0e25\u0e30\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 dispSides() \u0e08\u0e30\u0e17\u0e33\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e14\u0e31\u0e07\u0e01\u0e25\u0e48\u0e32\u0e27<\/p>\n<p>\u0e42\u0e14\u0e22\u0e2a\u0e32\u0e21\u0e40\u0e2b\u0e25\u0e35\u0e48\u0e22\u0e21\u0e01\u0e47\u0e40\u0e1b\u0e47\u0e19\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e02\u0e2d\u0e07 polygon \u0e0b\u0e36\u0e48\u0e07\u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a\u0e14\u0e49\u0e27\u0e22\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e02\u0e2d\u0e07\u0e14\u0e49\u0e32\u0e19 3 \u0e14\u0e49\u0e32\u0e19 \u0e14\u0e31\u0e07\u0e19\u0e31\u0e49\u0e19\u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e08\u0e30\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e04\u0e25\u0e32\u0e2a\u0e0a\u0e37\u0e48\u0e2d\u0e27\u0e48\u0e32 Triangle \u0e0b\u0e36\u0e48\u0e07\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e08\u0e32\u0e01 polygon \u0e0b\u0e36\u0e48\u0e07\u0e08\u0e30\u0e17\u0e33\u0e43\u0e2b\u0e49\u0e41\u0e2d\u0e17\u0e23\u0e34\u0e1a\u0e34\u0e27\u0e17\u0e4c\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\u0e17\u0e35\u0e48\u0e21\u0e35\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a Polygon \u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e44\u0e14\u0e49\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a Triangle \u0e42\u0e14\u0e22\u0e44\u0e21\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e04\u0e49\u0e14\u0e43\u0e2b\u0e21\u0e48\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e23\u0e30\u0e1a\u0e38<\/p>\n<pre class=\"prettyprint lang-python\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\r\nclass Triangle(Polygon):\r\n    def __init__(self):\r\n        Polygon.__init__(self,3)\r\n\r\n    def findArea(self):\r\n        a, b, c = self.sides\r\n        # calculate the semi-perimeter\r\n        s = (a + b + c) \/ 2\r\n        area = (s*(s-a)*(s-b)*(s-c)) ** 0.5\r\n        print('The area of the triangle is %0.2f' %area)\r\n<\/pre>\n<p>\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a Triangle \u0e40\u0e23\u0e32\u0e44\u0e14\u0e49\u0e17\u0e33\u0e01\u0e32\u0e23\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e43\u0e2b\u0e21\u0e48\u0e04\u0e37\u0e2d findArea() \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e08\u0e30\u0e17\u0e33\u0e01\u0e32\u0e23\u0e04\u0e33\u0e19\u0e27\u0e13\u0e41\u0e25\u0e30\u0e1e\u0e34\u0e21\u0e1e\u0e4c\u0e04\u0e48\u0e32\u0e02\u0e19\u0e32\u0e14\u0e02\u0e2d\u0e07\u0e1e\u0e37\u0e49\u0e19\u0e17\u0e35\u0e48\u0e02\u0e2d\u0e07\u0e2a\u0e32\u0e21\u0e40\u0e2b\u0e25\u0e35\u0e48\u0e22\u0e21<\/p>\n<pre class=\"prettyprint lang-python\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\r\nt = Triangle()\r\nt.inputSides()\r\n#Enter side 1: 3 \r\n#Enter side 2: 4 \r\n#Enter side 3: 5 \r\n\r\nt.dispSides()\r\nSide 1 is 3.0\r\nSide 2 is 4.0\r\nSide 3 is 5.0\r\n\r\nt.findArea()\r\nThe area of triangle is 6.0\r\n<\/pre>\n<p>\u0e08\u0e32\u0e01\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07 \u0e08\u0e30\u0e40\u0e2b\u0e47\u0e19\u0e27\u0e48\u0e32 \u0e41\u0e21\u0e49\u0e27\u0e48\u0e32\u0e40\u0e23\u0e32\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49\u0e17\u0e33\u0e01\u0e32\u0e23\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e40\u0e21\u0e17\u0e18\u0e2d\u0e14 inputSides() \u0e41\u0e25\u0e30 dispSides() \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e04\u0e25\u0e32\u0e2a Triangle \u0e41\u0e15\u0e48\u0e40\u0e23\u0e32\u0e01\u0e47\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e14\u0e49 \u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e21\u0e32\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a Polygon<\/p>\n<p>\u0e16\u0e49\u0e32\u0e41\u0e2d\u0e17\u0e23\u0e34\u0e1a\u0e34\u0e27\u0e17\u0e4c\u0e17\u0e35\u0e48\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e21\u0e48\u0e1e\u0e1a\u0e2d\u0e22\u0e39\u0e48\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38 \u0e08\u0e36\u0e07\u0e17\u0e33\u0e01\u0e32\u0e23\u0e04\u0e49\u0e19\u0e2b\u0e32\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e22\u0e31\u0e07\u0e04\u0e25\u0e32\u0e2a\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a(base class) \u0e41\u0e25\u0e30\u0e2b\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e14\u0e31\u0e07\u0e01\u0e25\u0e48\u0e32\u0e27 \u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e21\u0e32\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e2d\u0e37\u0e48\u0e19\u0e2d\u0e35\u0e01\u0e17\u0e35\u0e2b\u0e19\u0e36\u0e48\u0e07 \u0e01\u0e47\u0e08\u0e30\u0e17\u0e33\u0e40\u0e0a\u0e48\u0e19\u0e19\u0e35\u0e49\u0e44\u0e1b\u0e40\u0e23\u0e37\u0e48\u0e2d\u0e22\u0e46<\/p>\n<p><strong>\u0e01\u0e32\u0e23 Overriding \u0e40\u0e21\u0e17\u0e18\u0e2d\u0e14<\/strong><br \/>\n\u0e08\u0e32\u0e01\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e48\u0e41\u0e25\u0e49\u0e27 \u0e2a\u0e31\u0e07\u0e40\u0e01\u0e15\u0e38\u0e44\u0e14\u0e49\u0e27\u0e48\u0e32 \u0e40\u0e21\u0e17\u0e18\u0e2d\u0e14 __init__() \u0e16\u0e39\u0e01\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a\u0e17\u0e31\u0e49\u0e07\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a Polygon \u0e41\u0e25\u0e30 Triangle \u0e40\u0e21\u0e37\u0e48\u0e2d\u0e40\u0e01\u0e34\u0e14\u0e01\u0e23\u0e13\u0e35\u0e40\u0e0a\u0e48\u0e19\u0e19\u0e35\u0e49\u0e40\u0e21\u0e17\u0e18\u0e2d\u0e14\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(derived class) \u0e08\u0e30\u0e23\u0e30\u0e1a\u0e38\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e43\u0e2b\u0e49\u0e43\u0e2b\u0e21\u0e48(override) \u0e08\u0e32\u0e01\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e47\u0e04\u0e37\u0e2d\u0e04\u0e25\u0e32\u0e2a __init__ \u0e43\u0e19 Triangle \u0e44\u0e14\u0e49\u0e17\u0e33\u0e01\u0e32\u0e23\u0e23\u0e30\u0e1a\u0e38\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e02\u0e2d\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e19\u0e35\u0e49\u0e43\u0e2b\u0e21\u0e48\u0e41\u0e17\u0e19\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e08\u0e32\u0e01\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 __init__ \u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a Polygon<\/p>\n<p>\u0e42\u0e14\u0e22\u0e2a\u0e48\u0e27\u0e19\u0e43\u0e2b\u0e0d\u0e48\u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e01\u0e32\u0e23 overriding \u0e19\u0e35\u0e49\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e08\u0e30\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e04\u0e27\u0e32\u0e21\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e2b\u0e49\u0e40\u0e21\u0e17\u0e18\u0e2d\u0e14\u0e21\u0e32\u0e01\u0e01\u0e27\u0e48\u0e32\u0e17\u0e35\u0e48\u0e08\u0e30\u0e40\u0e02\u0e35\u0e22\u0e19\u0e04\u0e27\u0e32\u0e21\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e41\u0e17\u0e19\u0e17\u0e35\u0e48\u0e25\u0e07\u0e44\u0e1b\u0e2b\u0e21\u0e14 \u0e01\u0e32\u0e23\u0e17\u0e33\u0e41\u0e1a\u0e1a\u0e19\u0e35\u0e49\u0e08\u0e30\u0e17\u0e33\u0e44\u0e14\u0e49\u0e42\u0e14\u0e22\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a\u0e08\u0e32\u0e01\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e0a\u0e37\u0e48\u0e2d\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e20\u0e32\u0e22\u0e43\u0e19\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e01 Polygon.__init__() \u0e08\u0e32\u0e01 Triangle.__init__())<\/p>\n<p>\u0e2d\u0e35\u0e01\u0e17\u0e32\u0e07\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e17\u0e35\u0e48\u0e14\u0e35\u0e01\u0e27\u0e48\u0e32\u0e04\u0e37\u0e2d\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49 built-in \u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 super().__init__(3) \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e47\u0e40\u0e17\u0e35\u0e22\u0e1a\u0e40\u0e17\u0e48\u0e32\u0e01\u0e31\u0e1a\u0e40\u0e23\u0e32\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49 Polygon(self, 3) \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e41\u0e1a\u0e1a\u0e19\u0e35\u0e49\u0e04\u0e48\u0e2d\u0e19\u0e02\u0e49\u0e32\u0e07\u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e17\u0e35\u0e48\u0e19\u0e34\u0e22\u0e21\u0e21\u0e32\u0e01\u0e27\u0e48\u0e32<\/p>\n<p>\u0e22\u0e31\u0e07\u0e21\u0e35 built-in \u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 isinstance() \u0e41\u0e25\u0e30 issubclass() \u0e0b\u0e36\u0e48\u0e07\u0e16\u0e39\u0e01\u0e43\u0e0a\u0e49\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e08\u0e30\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e19\u0e31\u0e49\u0e19\u0e46 \u0e42\u0e14\u0e22\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 isinstance() \u0e08\u0e30\u0e04\u0e37\u0e19\u0e04\u0e48\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e08\u0e23\u0e34\u0e07\u0e01\u0e47\u0e15\u0e48\u0e2d\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e2d\u0e2d\u0e1a\u0e40\u0e08\u0e04\u0e19\u0e31\u0e49\u0e19\u0e40\u0e1b\u0e47\u0e19 instance \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e02\u0e2d\u0e07\u0e04\u0e25\u0e32\u0e2a\u0e19\u0e31\u0e49\u0e19 \u0e2b\u0e23\u0e37\u0e2d\u0e04\u0e25\u0e32\u0e2a\u0e2d\u0e37\u0e48\u0e19\u0e17\u0e35\u0e48\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e21\u0e32\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e19\u0e31\u0e49\u0e19\u0e2d\u0e35\u0e01\u0e17\u0e35 \u0e42\u0e14\u0e22\u0e17\u0e38\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e43\u0e19\u0e44\u0e1e\u0e18\u0e2d\u0e19\u0e08\u0e30\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e21\u0e32\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a object \u0e40\u0e2a\u0e21\u0e2d<\/p>\n<pre class=\"prettyprint lang-python\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\r\nt = Triangle()\r\n\r\nisinstance(t, Triangle)\r\n# True\r\n\r\nisinstance(t, Polygon)\r\n# True\r\n\r\nisinstance(t, int)\r\n# False\r\n\r\nisinstance(t, object)\r\n# True\r\n<\/pre>\n<p>\u0e43\u0e19\u0e17\u0e33\u0e19\u0e2d\u0e07\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19 \u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 issubclass() \u0e43\u0e0a\u0e49\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e02\u0e2d\u0e07\u0e04\u0e25\u0e32\u0e2a\u0e40\u0e0a\u0e48\u0e19\u0e01\u0e31\u0e19<\/p>\n<pre class=\"prettyprint lang-python\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\r\nt = Triangle()\r\n\r\nissubclass(Polygon, Triangle)\r\n# False\r\n\r\nissubclass(Triangle, Polygon)\r\n# True\r\n\r\nissubclass(bool, int)\r\n# True\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(Inheritance) \u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e40\u0e14\u0e48\u0e19\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21\u0e41\u0e1a\u0e1a OO(Object-Oriented Programming) \u0e42\u0e14\u0e22\u0e2d\u0e49\u0e32\u0e07\u0e16\u0e36\u0e07\u0e01\u0e32\u0e23\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e25\u0e32\u0e2a\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e43\u0e2b\u0e21\u0e48\u0e41\u0e25\u0e30\u0e14\u0e49\u0e27\u0e22\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e17\u0e35\u0e48\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e42\u0e14\u0e22\u0e44\u0e21\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e41\u0e01\u0e49\u0e44\u0e02\u0e43\u0e14\u0e46 \u0e42\u0e14\u0e22\u0e04\u0e25\u0e32\u0e2a\u0e43\u0e2b\u0e21\u0e48\u0e40\u0e23\u0e35\u0e22\u0e01\u0e27\u0e48\u0e32\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(derived or child class) \u0e41\u0e25\u0e30\u0e04\u0e25\u0e32\u0e2a\u0e17\u0e35\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a\u0e02\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e19\u0e31\u0e49\u0e19\u0e40\u0e23\u0e35\u0e22\u0e01\u0e27\u0e48\u0e32\u0e04\u0e25\u0e32\u0e2a base(\u0e2b\u0e23\u0e37\u0e2d parent) class BaseClass: # \u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e02\u0e2d\u0e07 Base Class class DerivedClass(BaseClass): # \u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14\u0e02\u0e2d\u0e07 Derived Class \u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14(derived class) \u0e44\u0e14\u0e49\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e08\u0e32\u0e01\u0e04\u0e25\u0e32\u0e2a\u0e15\u0e49\u0e19\u0e41\u0e1a\u0e1a \u0e41\u0e25\u0e30\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e43\u0e2b\u0e21\u0e48\u0e25\u0e07\u0e44\u0e1b\u0e44\u0e14\u0e49 \u0e0b\u0e36\u0e48\u0e07\u0e17\u0e33\u0e43\u0e2b\u0e49\u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e04\u0e25\u0e32\u0e2a\u0e43\u0e2b\u0e21\u0e48\u0e42\u0e14\u0e22\u0e01\u0e32\u0e23\u0e19\u0e33\u0e04\u0e38\u0e13\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e40\u0e14\u0e34\u0e21\u0e17\u0e35\u0e48\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e41\u0e25\u0e49\u0e27\u0e21\u0e32\u0e1b\u0e23\u0e31\u0e1a\u0e1b\u0e23\u0e38\u0e07\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e14\u0e49\u0e21\u0e32\u0e01\u0e02\u0e36\u0e49\u0e19 \u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e37\u0e1a\u0e17\u0e2d\u0e14 \u0e01\u0e33\u0e2b\u0e19\u0e14\u0e43\u0e2b\u0e49 polygon \u0e40\u0e1b\u0e47\u0e19\u0e23\u0e39\u0e1b\u0e1b\u0e34\u0e14\u0e0b\u0e36\u0e48\u0e07\u0e21\u0e35\u0e14\u0e49\u0e32\u0e07 3 \u0e14\u0e49\u0e32\u0e19 \u0e40\u0e23\u0e32\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e04\u0e25\u0e32\u0e2a polygon \u0e44\u0e14\u0e49\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49 class Polygon: def __init__(self, no_of_sides): self.n = no_of_sides self.sides = [0 for i in range(no_of_sides)] def inputSides(self): <a href=\"https:\/\/www.booboohome.com\/blogs\/2018\/06\/python-inheritance\/\" rel=\"nofollow\"><span class=\"sr-only\">Read more about Python &#8211; Inheritance<\/span>[&hellip;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91,95],"tags":[176,92,113,177,115,94,332,333,114],"class_list":["post-1712","post","type-post","status-publish","format-standard","hentry","category-python","category-python-tutorial","tag-inheritance","tag-python","tag-python-tutorial","tag-177","tag-115","tag-94","tag-332","tag-333","tag-114"],"_links":{"self":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts\/1712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/comments?post=1712"}],"version-history":[{"count":4,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts\/1712\/revisions"}],"predecessor-version":[{"id":3566,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts\/1712\/revisions\/3566"}],"wp:attachment":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/media?parent=1712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/categories?post=1712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/tags?post=1712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}