Unit 2 Python Ppt Prabha(1)
Unit 2 Python Ppt Prabha(1)
PREPARED BY
DR. SHANMUGA PRABHA P
ASSISTANT PROFESSOR
DEPT. OF CSE
Python is an object-oriented programming language. This means that almost all the code is
implemented using a special construct called classes. A class is a code template for creating
objects.
•Class: The class is a user-defined data structure that binds the data members and methods
into a single unit. Class is a blueprint or code template for object creation. Using a class,
you can create as many objects as you want.
Objects have two characteristics: They have states and behaviors (object has attributes
and methods attached to it) Attributes represent its state, and methods represent its behavior.
Using its methods, we can modify its state.
For example, a car is an object, and its properties are car color, sunroof, price,
manufacture, model, engine, and so on. Here, color is the name and red is the value.
Object properties are nothing but instance variables.
Modify Object Properties
Every object has properties associated with them. We can set or modify the
object’s properties after object initialization by calling the property directly
using the dot operator.
Obj.PROPERTY = value
Delete Objects
n Python, we can also delete the object by using a del keyword.
I
An object can be anything like, class object, list, tuple, set, etc.
Constructors in Python
Constructor is a special method used to create and initialize an object of a class. On the
other hand, a destructor is used to destroy the object.