SlideShare a Scribd company logo
1 of 20
to
Object-Oriented
IN PYTHON
to
Object-Oriented
IN PYTHON
Introduction to
Polymorphism
01
Types of polymorphism
02
With inheritance
03
04
Purpose of interface
05
Conclusion
TABLE OF CONTENTS.
Introduction to
Polymorphism
01
TABLE OF CONTENTS.
Introduction to Polymorphism
● Polymorphism is a fundamental concept
in object-oriented programming (OOP).
● It refers to the ability of objects
to exhibit different behaviors based
on their data type or class.
Introduction to Polymorphism
The constructor method is optional, and if
not defined, Python provides a default
constructor.
Introduction to Constructor
Types of polymorphism
Duck Typing:
Method Overloading:
DID YOU KNOW?
•In Python, polymorphism is primarily
achieved through duck typing.
•It focuses on the behavior of objects
rather than their types.
•Objects are considered to be of the
same type if they have compatible
methods and attributes.
Duck
DID YOU KNOW?
•Method overloading allows a class to
have multiple methods with the same
name but different parameters.
•Python does not support method
overloading directly, but it can be
achieved using default values or
variable-length arguments.
Method
With inheritance
•Inheritance and polymorphism work
together, allowing objects of different
classes to respond differently to the
same method call based on their specific
types.
•Polymorphism can be achieved through
method overriding, where a subclass
provides its own implementation of a
method inherited from its parent class.
DID YOU KNOW?
• Achieve a form of interface-like
behavior by using abstract base
classes.
• The @0abstractmethod decorator
marks the method as abstract,
indicating that any class inheriting
from MyInterface must provide its
own implementation
of my_method().
Interface
Conclusion
Interface
•In Python, there is no explicit keyword for
defining interfaces like in some other
programming languages.
•However, interface-like behavior can be
achieved using abstract base classes .
•An interface defines a set of methods that a
class must implement to conform to the
interface.
•Abstract methods, marked with
the @abstractmethod decorator, serve as
placeholders for method definitions in the
interface.
•Classes that inherit from an interface must
provide implementations for all the abstract
methods.
Conclusion
Polymorphism
•Polymorphism is a fundamental concept
in object-oriented programming.
•It allows objects of different classes to be
treated as objects of a common base class,
enabling them to exhibit different
behaviors.
•Polymorphism is achieved through
method overriding, where a subclass
provides its own implementation of a
method inherited from its parent class.
•Method calls on objects are resolved at
runtime based on the actual object's type,
allowing different objects to respond
differently to the same method call.
•Polymorphism promotes code reusability,
flexibility, and extensibility by providing a
common interface for interacting with
diverse objects.
THANK
YOU! ● Constructor
● Destructor

More Related Content

Similar to Polymorphism.pptx

Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfDatacademy.ai
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
AkhileshD_Presentation_Core_Java_OOPs.pptx
AkhileshD_Presentation_Core_Java_OOPs.pptxAkhileshD_Presentation_Core_Java_OOPs.pptx
AkhileshD_Presentation_Core_Java_OOPs.pptxAkhilesh740777
 
polymorphismppt for Computer Applications-211218133624.pptx
polymorphismppt for  Computer Applications-211218133624.pptxpolymorphismppt for  Computer Applications-211218133624.pptx
polymorphismppt for Computer Applications-211218133624.pptxwaarrior1234567
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingMH Abid
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python ProgrammingKAUSHAL KUMAR JHA
 
OOPS – General Understanding in .NET
OOPS – General Understanding in .NETOOPS – General Understanding in .NET
OOPS – General Understanding in .NETSabith Byari
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesHabtamu Wolde
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in pythonnitamhaske
 
Object oriented programming 6 oop with c++
Object oriented programming 6  oop with c++Object oriented programming 6  oop with c++
Object oriented programming 6 oop with c++Vaibhav Khanna
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersMadhavendra Dutt
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerJeba Moses
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfJP Chicano
 

Similar to Polymorphism.pptx (20)

Learn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdfLearn Polymorphism in Python with Examples.pdf
Learn Polymorphism in Python with Examples.pdf
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
AkhileshD_Presentation_Core_Java_OOPs.pptx
AkhileshD_Presentation_Core_Java_OOPs.pptxAkhileshD_Presentation_Core_Java_OOPs.pptx
AkhileshD_Presentation_Core_Java_OOPs.pptx
 
polymorphismppt for Computer Applications-211218133624.pptx
polymorphismppt for  Computer Applications-211218133624.pptxpolymorphismppt for  Computer Applications-211218133624.pptx
polymorphismppt for Computer Applications-211218133624.pptx
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
OOPS – General Understanding in .NET
OOPS – General Understanding in .NETOOPS – General Understanding in .NET
OOPS – General Understanding in .NET
 
Object Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and InterfacesObject Oriented Programming - Polymorphism and Interfaces
Object Oriented Programming - Polymorphism and Interfaces
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Object oriented programming 6 oop with c++
Object oriented programming 6  oop with c++Object oriented programming 6  oop with c++
Object oriented programming 6 oop with c++
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
oop.pptx
oop.pptxoop.pptx
oop.pptx
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdf
 

Recently uploaded

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 

Recently uploaded (20)

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Polymorphism.pptx

  • 1.
  • 4.
  • 5.
  • 6. Introduction to Polymorphism 01 Types of polymorphism 02 With inheritance 03 04 Purpose of interface 05 Conclusion TABLE OF CONTENTS.
  • 8. Introduction to Polymorphism ● Polymorphism is a fundamental concept in object-oriented programming (OOP). ● It refers to the ability of objects to exhibit different behaviors based on their data type or class.
  • 10. The constructor method is optional, and if not defined, Python provides a default constructor. Introduction to Constructor
  • 11. Types of polymorphism Duck Typing: Method Overloading:
  • 12.
  • 13. DID YOU KNOW? •In Python, polymorphism is primarily achieved through duck typing. •It focuses on the behavior of objects rather than their types. •Objects are considered to be of the same type if they have compatible methods and attributes. Duck
  • 14. DID YOU KNOW? •Method overloading allows a class to have multiple methods with the same name but different parameters. •Python does not support method overloading directly, but it can be achieved using default values or variable-length arguments. Method
  • 15.
  • 16. With inheritance •Inheritance and polymorphism work together, allowing objects of different classes to respond differently to the same method call based on their specific types. •Polymorphism can be achieved through method overriding, where a subclass provides its own implementation of a method inherited from its parent class.
  • 17. DID YOU KNOW? • Achieve a form of interface-like behavior by using abstract base classes. • The @0abstractmethod decorator marks the method as abstract, indicating that any class inheriting from MyInterface must provide its own implementation of my_method(). Interface
  • 18. Conclusion Interface •In Python, there is no explicit keyword for defining interfaces like in some other programming languages. •However, interface-like behavior can be achieved using abstract base classes . •An interface defines a set of methods that a class must implement to conform to the interface. •Abstract methods, marked with the @abstractmethod decorator, serve as placeholders for method definitions in the interface. •Classes that inherit from an interface must provide implementations for all the abstract methods.
  • 19. Conclusion Polymorphism •Polymorphism is a fundamental concept in object-oriented programming. •It allows objects of different classes to be treated as objects of a common base class, enabling them to exhibit different behaviors. •Polymorphism is achieved through method overriding, where a subclass provides its own implementation of a method inherited from its parent class. •Method calls on objects are resolved at runtime based on the actual object's type, allowing different objects to respond differently to the same method call. •Polymorphism promotes code reusability, flexibility, and extensibility by providing a common interface for interacting with diverse objects.