[go: up one dir, main page]

0% found this document useful (0 votes)
585 views10 pages

OOP Concepts in Python Explained

The document provides an overview of Object-Oriented Programming (OOP) in Python, highlighting its core principles such as classes, objects, inheritance, encapsulation, polymorphism, and abstraction. It explains how OOP allows developers to create modular and maintainable applications by binding data and functions together. Additionally, it covers class creation, function definitions within classes, inheritance, overriding methods, and polymorphism in Python.

Uploaded by

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

OOP Concepts in Python Explained

The document provides an overview of Object-Oriented Programming (OOP) in Python, highlighting its core principles such as classes, objects, inheritance, encapsulation, polymorphism, and abstraction. It explains how OOP allows developers to create modular and maintainable applications by binding data and functions together. Additionally, it covers class creation, function definitions within classes, inheritance, overriding methods, and polymorphism in Python.

Uploaded by

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

OOPS IN PYTHON

SNEHA ARUN NAIK


INTRODUCTION TO OOPS CONCEPT

• 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—programmers can leverage the full potential of Python’s OOP capabilities to
design elegant and efficient solutions to complex problems

• What is Object-Oriented Programming in Python?


 In Python object-oriented Programming (OOPs) is a programming paradigm that uses
objects and classes in programming. It aims to implement real-world entities like
inheritance, polymorphisms, encapsulation, etc. in the programming. The main concept of
object-oriented Programming (OOPs) or oops concepts in Python is to bind the data and
the functions that work together as a single unit so that no other part of the code can
access this data.
OOPS CONCEPTS IN
PYTHON
 Class in Python
 Objects in Python
 Polymorphism in Python
 Encapsulation in Python
 Inheritance in Python
 Data Abstraction in Python
CREATING CLASSES

• Defining a class in Python is done using the class keyword, followed by


an indented block with the class contents. Defining a class in Python is
done using the class keyword, followed by an indented block with the
class contents.
DEFINING FUNCTIONS IN CLASSES

• definition block can include multiple functions. • A class defini on block


can include multiple functions.
• These represent the functionality or behaviors that are associated with
the class.

Argument (self) refers to the object itself


CALLING FUNCTIONS IN CLASSES

• Using class functions from • Using class functions from inside


outside classes, functions are class
referenced by dot syntax: • When referring functions from
<object name>.<method
within a class we must always
name>
prefix the functions with name
self(e.g. [Link]())
INHERITANCE

• Class inheritance is designed to model relationships of the type "x is a y"


(e.g. "a triangle is a shape")

• The functions and attributes of a superclass are inherited by a subclass.


• An inherited class can override, modify or augment the functions and
attributes of its parent class.
CREATING SUBCLASSES
OVERRIDING

• When inheriting from a class, we can alter the behavior of the original
superclass by "overriding" functions (i.e. declaring func ons in the
subclass with the same name).
• Functions in a subclass take precedence over functions in a superclass.
POLYMORPHISM

• Two objects of different classes but supporting the same set of


functions or attributes can be treated identically.
• The implementations may differ internally, but the outward
"appearance" is the same.
• Two different classes that contain the function area()

You might also like