Ex.
No : 13
Class and Object in Python
Aim:
To understand the concept of class and object in Python and implement real-time programs using classes.
Theory:
A class is a blueprint for creating objects. An object is an instance of a class. Classes contain variables
(attributes) and functions (methods) that define the behavior of objects.
13.1 Program to Create a Simple Class and Object
Program:
class Demo:
def show(self):
print("This is a simple class example")
obj = Demo()
[Link]()
Sample Output:
This is a simple class example
Result:
The program for "Class and Object in Python" was executed successfully and the output was verified.
Ex. No : 14
Constructors in Python
Aim:
To understand the concept of constructors in Python and implement different types of constructors.
Theory:
A constructor is a special method used to initialize objects. In Python, the constructor is defined using
__init__() method.
14.1 Program Using Default Constructor
Program:
class Demo:
def __init__(self):
print("Default Constructor Called")
obj = Demo()
Sample Output:
Default Constructor Called
Result:
The program for "Constructors in Python" was executed successfully and the output was verified.