0% found this document useful (0 votes)
0 views4 pages

Object Oriented Programming is a fundamental concept in Python

Object Oriented Programming (OOP) in Python enables the creation of modular and scalable applications through principles like classes, objects, inheritance, encapsulation, polymorphism, and abstraction. Key concepts include class and instance variables, types of inheritance, and methods of polymorphism, all of which facilitate code organization and reuse. The four pillars of OOP in Python are encapsulation, abstraction, inheritance, and polymorphism.

Uploaded by

vikash012017
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
0 views4 pages

Object Oriented Programming is a fundamental concept in Python

Object Oriented Programming (OOP) in Python enables the creation of modular and scalable applications through principles like classes, objects, inheritance, encapsulation, polymorphism, and abstraction. Key concepts include class and instance variables, types of inheritance, and methods of polymorphism, all of which facilitate code organization and reuse. The four pillars of OOP in Python are encapsulation, abstraction, inheritance, and polymorphism.

Uploaded by

vikash012017
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Object Oriented Programming is a fundamental concept in Python,

empowering developers to build modular, maintainable, and scalable


applications. By understanding the core OOP principles (classes, objects,
inheritance, encapsulation, polymorphism, and abstraction
OOPs is a way of organizing code that uses objects and classes to represent
real-world entities and their behavior.

OOPs Concepts in Python


 Class in Python
 Objects in Python
 Polymorphism in Python
 Encapsulation in Python
 Inheritance in Python
 Data Abstraction in Python

Python Class
A class is a collection of objects. classes are blueprints for creating objects. A
class defines a set of attributes and methods that the created objects
(instances) can have.
Some points on Python class:
 Classes are created by keyword class.
 Attributes are the variables that belong to a class.

Python Objects
An Object is an instance of a Class. It represents a specific implementation of
the class and holds its own data.
An object consists of:
 State: It is represented by the attributes and reflects the properties of an
object.
 Behavior: It is represented by the methods of an object and reflects the
response of an object to other objects.
Class Variables
These are the variables that are shared across all instances of a class. It is
defined at the class level, outside any methods. All objects of the class share
the same value for a class variable unless explicitly overridden in an object.

Instance Variables
Variables that are unique to each instance (object) of a class. These are
defined within the __init__ method or other instance methods. Each object
maintains its own copy of instance variables, independent of other objects.

Python Inheritance
Inheritance allows a class (child class) to acquire properties and methods of
another class (parent class). It supports hierarchical classification and
promotes code reuse.
Types of Inheritance:
1.Single Inheritance: A child class inherits from a single parent class.
2. Multiple Inheritance: A child class inherits from more than one parent
class.
3. Multilevel Inheritance: A child class inherits from a parent class, which in
turn inherits from another class.

Python Polymorphism
Polymorphism allows methods to have the same name but behave differently
based on the object’s context. It can be achieved through method overriding
or overloading.
Types of Polymorphism
1. Compile-Time Polymorphism: This type of polymorphism is determined
during the compilation of the program. It allows methods or operators with
the same name to behave differently based on their input parameters or
usage. It is commonly referred to as method or operator overloading.
2. Run-Time Polymorphism: This type of polymorphism is determined during
the execution of the program. It occurs when a subclass provides a specific
implementation for a method already defined in its parent class, commonly
known as method overriding.
Python Encapsulation
Encapsulation is the bundling of data (attributes) and methods (functions)
within a class, restricting access to some components to control interactions.
A class is an example of encapsulation as it encapsulates all the data that is
member functions, variables, etc.
Types of Encapsulation:
1. Public Members: Accessible from anywhere.
2. Protected Members: Accessible within the class and its subclasses.
3. Private Members: Accessible only within the class.

Data Abstraction
ABSTRACTION hides the internal implementation details while exposing
only the necessary functionality. It helps focus on “what to do” rather than
“how to do it.”
Types of Abstraction:
 Partial Abstraction: Abstract class contains both abstract and concrete
methods.
 Full Abstraction: Abstract class contains only abstract methods (like
interfaces).

What are the 4 pillars of OOP Python?


The 4 pillars of object-oriented programming (OOP) in Python (and generally
in programming) are:
 Encapsulation: Bundling data (attributes) and methods (functions) that
operate on the data into a single unit (class).
 Abstraction: Hiding complex implementation details and providing a
simplified interface.
 Inheritance: Allowing a class to inherit attributes and methods from
another class, promoting code reuse.
 Polymorphism: Using a single interface to represent different data types
or objects.

You might also like