0% found this document useful (0 votes)
3 views1 page

Python OOP Concepts Explained

Uploaded by

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

Python OOP Concepts Explained

Uploaded by

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

Object-Oriented Programming (OOP) Concepts in

Python

Object-Oriented Programming (OOP) is a programming paradigm that uses objects and classes to
structure code. Python fully supports OOP, allowing developers to model real-world entities with
attributes (data) and behaviors (methods).

• Class: A blueprint for creating objects. Defines attributes (variables) and methods (functions).
• Object: An instance of a class. Represents a specific entity created using the class blueprint.
• Constructor (__init__): A special method automatically called when a new object is created.
Used to initialize attributes.
• Attributes: Variables that hold data associated with an object.
• Methods: Functions defined inside a class that describe the behavior of objects.
• Inheritance: Allows one class (child) to derive properties and methods from another (parent).
Promotes code reusability.
• Encapsulation: Hiding implementation details of a class and restricting direct access.
Achieved using private/protected members.
• Polymorphism: Ability of different classes to provide different implementations for the same
method name.
• Abstraction: Showing only essential features of an object and hiding the background details.

Example in Python:
class Employee:
def __init__(self, name, age):
[Link] = name
[Link] = age

def display_info(self):
print(f'Name: {[Link]}, Age: {[Link]}')

# Create object
emp1 = Employee('Rajesh', 30)
emp1.display_info()

You might also like