0% found this document useful (0 votes)
2 views2 pages

Python Practical File BW

The document explains the concepts of classes and objects in Python, including their definitions and implementations through example programs. It also covers constructors, specifically the default constructor using the __init__() method. Both examples demonstrate successful execution and output verification.

Uploaded by

faizan124513
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Python Practical File BW

The document explains the concepts of classes and objects in Python, including their definitions and implementations through example programs. It also covers constructors, specifically the default constructor using the __init__() method. Both examples demonstrate successful execution and output verification.

Uploaded by

faizan124513
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.

You might also like