Posted in Python Examples

parameterized Constructor Example in Python

class Demo: b=0 def __init__(self,m): self.b=m f=Demo(10) print(f.b)

Continue Reading...

parameterized Constructor Example in Python

Posted in Python Examples

Default Constructor Example in Python

class Division: a=0 b=0 def __init__(self): self.b=1 def display(self): print(self.a/self.b) d=Division() d.display()

Continue Reading...

Default Constructor Example in Python

Posted in Python Examples

Super Example in Python

class Base: def geta(self): return 10 def getb(self): return 20 class Derived(Base): def geta(self): return 100 def sum(self): print(super().geta()+self.geta()+self.getb()) d=Derived() d.sum()

Continue Reading...

Super Example in Python

Posted in Python Examples

Function OverRiding Example in Python

class Base: a=10 def geta(self): return self.a def getb(self): return 20 class Derived1(Base): def geta(self): return 100 def sum(self): return(self.geta()+self.geta()+self.getb()) d1=Derived1() print(d1.sum());

Continue Reading...

Function OverRiding Example in Python

Posted in Python Examples

Hybrid Inheritance Example in Python

class Base: def geta(self): return 10 def getb(self): return 20 class Derived1(Base): def sum(self): return(self.geta()+self.getb()) class Derived2(Base): def sub(self): return(self.getb()-self.geta()) class LastDerived(Derived1,Derived2): def avg(self): print(self.sum()+self.sub())…

Continue Reading...

Hybrid Inheritance Example in Python

Posted in Python Examples

Multiple Inheritance Example in Python

class Base1: def geta(self): return 10 class Base2: def getb(self): return 20 class Add(Base1,Base2): def sum(self): print(self.geta()+self.getb()) x=Add() x.sum()

Continue Reading...

Multiple Inheritance Example in Python

Posted in Python Examples

Hierarchical Inheritance Example in Python

class Base: def geta(self): return 10 def getb(self): return 20 class Add(Base): def sum(self): print(self.geta()+self.getb()) class Minus(Base): def sub(self): print(self.geta()-self.getb()) f1=Add() f1.sum() f2=Minus() f2.sub()

Continue Reading...

Hierarchical Inheritance Example in Python

Posted in Python Examples

Multilevel Inheritance Example in Python

class Base: def geta(self): return 10 def getb(self): return 20 class Derived(Base): def sum(self): return (self.geta()+self.getb()) class LastDerived(Derived): def avg(self): print(self.sum()/2) Id=LastDerived() Id.avg()

Continue Reading...

Multilevel Inheritance Example in Python

Posted in Python Examples

Single Inheritance Example in Python

class Base: def geta(self): return 10 def getb(self): return 20 class Derived(Base): def sum(self): print(self.geta()+self.getb()) d=Derived() d.sum()

Continue Reading...

Single Inheritance Example in Python

Posted in Python Examples

Class2 Example in Python

class Student(): def display(self,a,b): print(“sum”,(a+b)) s=Student() s.display(10,20)

Continue Reading...

Class2 Example in Python