Classes in Python programming is a building block that leads to OOP. It is user-defined data type which combines data and methods for manipulating that data into one package. In the following programs you will learn that how to use multiple classes in python program.
class cls: #this is class.
def fun(self):
print("This is Function of Class cls")
class cls2: #this is class.
def fun2(self):
print("This is Function of Class cls2")
class cls3: #this is class.
def fun3(self):
print("This is Function of Class cls3")
obj = cls() #'obj' is object of class 'cls'.
obj.fun()
obj2 = cls2() #'obj2' is object of class 'cls2'.
obj2.fun2()
obj3 = cls3() #'obj3' is object of class 'cls3'.
obj3.fun3()
class cls: #this is class.
def __init__(self):
print("This is Default Constructor of Class cls")
def fun(self):
print("This is Function of Class cls")
class cls2: #this is class.
def __init__(self):
print("This is Default Constructor of Class cls2")
def fun2(self):
print("This is Function of Class cls2")
class cls3: #this is class.
def __init__(self):
print("This is Default Constructor of Class cls3")
def fun3(self):
print("This is Function of Class cls3")
obj = cls() #'obj' is object of class 'cls'.
obj.fun()
obj2 = cls2() #'obj2' is object of class 'cls2'.
obj2.fun2()
obj3 = cls3() #'obj3' is object of class 'cls3'.
obj3.fun3()
class cls: #this is class.
def __init__(self):
print("This is Default Constructor of Class cls")
def fun(self):
print("This is Function of Class cls")
obj3 = cls3() #'obj3' is object of class 'cls3'.
obj3.fun3()
class cls2: #this is class.
def __init__(self):
print("This is Default Constructor of Class cls2")
def fun2(self):
print("This is Function of Class cls2")
obj = cls() #'obj' is object of class 'cls'.
obj.fun()
class cls3: #this is class.
def __init__(self):
print("This is Default Constructor of Class cls3")
def fun3(self):
print("This is Function of Class cls3")
obj2 = cls2() #'obj2' is object of class 'cls2'.
obj2.fun2()