SlideShare a Scribd company logo
1 of 11
POLYMORPHISM
PRESENTED BY:
SIMRAN PARDESHI (36)
INTRODUCTION
• In programming, polymorphism means the same function name (but different
signatures) being used for different types.
• In Python, Polymorphism lets us define methods in the child class that have
the same name as the methods in the parent class. In inheritance, the child
class inherits the methods from the parent class. However, it is possible to
modify a method in a child class that it has inherited from the parent class.
Exampleof inbuilt polymorphic functions:
• CODE:
• OUTPUT:
Polymorphism with class methods:
• The below code shows how Python can use two different class types, in the same way. We create a for
loop that iterates through a tuple of objects. Then call the methods without being concerned about
which class type each object is. We assume that these methods actually exist in each class.
• CODE:
• OUTPUT:
Polymorphismwith Inheritance:
• In Python, Polymorphism lets us define methods in the child class that have the same name
as the methods in the parent class. In inheritance, the child class inherits the methods from
the parent class. However, it is possible to modify a method in a child class that it has
inherited from the parent class. This is particularly useful in cases where the method
inherited from the parent class doesn’t quite fit the child class. In such cases, we re-
implement the method in the child class. This process of re-implementing method in the
child class is known as Method Overriding.
• CODE:
• OUTPUT:
CONCLUSION
•Polymorphism is a very important concept in Object-
Oriented Programming. We can use the concept of
polymorphism while creating class methods as Python
allows different classes to have methods with the same
name.
THANK YOU!

More Related Content

What's hot

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 

What's hot (20)

Python-Inheritance.pptx
Python-Inheritance.pptxPython-Inheritance.pptx
Python-Inheritance.pptx
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Packages In Python Tutorial
Packages In Python TutorialPackages In Python Tutorial
Packages In Python Tutorial
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Python programming : Inheritance and polymorphism
Python programming : Inheritance and polymorphismPython programming : Inheritance and polymorphism
Python programming : Inheritance and polymorphism
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructors
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Python-DataAbstarction.pptx
Python-DataAbstarction.pptxPython-DataAbstarction.pptx
Python-DataAbstarction.pptx
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 

Similar to Polymorphism in Python

polymorphismppt for Computer Applications-211218133624.pptx
polymorphismppt for  Computer Applications-211218133624.pptxpolymorphismppt for  Computer Applications-211218133624.pptx
polymorphismppt for Computer Applications-211218133624.pptx
waarrior1234567
 

Similar to Polymorphism in Python (20)

polymorphismppt for Computer Applications-211218133624.pptx
polymorphismppt for  Computer Applications-211218133624.pptxpolymorphismppt for  Computer Applications-211218133624.pptx
polymorphismppt for Computer Applications-211218133624.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.pdf
 
Polymorphism.pptx
Polymorphism.pptxPolymorphism.pptx
Polymorphism.pptx
 
28c
28c28c
28c
 
28csharp
28csharp28csharp
28csharp
 
Object Oriented Programming.pptx
Object Oriented Programming.pptxObject Oriented Programming.pptx
Object Oriented Programming.pptx
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oops
OopsOops
Oops
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
Questpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPSQuestpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPS
 
javainheritance
javainheritancejavainheritance
javainheritance
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
 
AkhileshD_Presentation_Core_Java_OOPs.pptx
AkhileshD_Presentation_Core_Java_OOPs.pptxAkhileshD_Presentation_Core_Java_OOPs.pptx
AkhileshD_Presentation_Core_Java_OOPs.pptx
 
Java
JavaJava
Java
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 

More from Home

More from Home (20)

DIABETES PREDICTION SYSTEM .pptx
DIABETES PREDICTION SYSTEM .pptxDIABETES PREDICTION SYSTEM .pptx
DIABETES PREDICTION SYSTEM .pptx
 
data science pptx
data science pptxdata science pptx
data science pptx
 
HARDWARE AND SOFTWARE.pptx
HARDWARE AND SOFTWARE.pptxHARDWARE AND SOFTWARE.pptx
HARDWARE AND SOFTWARE.pptx
 
Rock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxRock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptx
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptx
 
Fighting climate change using agritech
Fighting climate change using agritech Fighting climate change using agritech
Fighting climate change using agritech
 
APPLICATION OF GROUPS IN CRYPTOGRAPHY
APPLICATION OF GROUPS IN CRYPTOGRAPHYAPPLICATION OF GROUPS IN CRYPTOGRAPHY
APPLICATION OF GROUPS IN CRYPTOGRAPHY
 
ECONOMIC RIGHTS.pptx
ECONOMIC RIGHTS.pptxECONOMIC RIGHTS.pptx
ECONOMIC RIGHTS.pptx
 
Hamiltonian cycle in data structure 2
Hamiltonian cycle in data structure  2Hamiltonian cycle in data structure  2
Hamiltonian cycle in data structure 2
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
 
Water scarcity and its remedial measures
Water scarcity and its remedial measuresWater scarcity and its remedial measures
Water scarcity and its remedial measures
 
Multimedia operating system
Multimedia operating systemMultimedia operating system
Multimedia operating system
 
Dsdco IE: RISC and CISC architectures and design issues
Dsdco IE: RISC and CISC architectures and design issuesDsdco IE: RISC and CISC architectures and design issues
Dsdco IE: RISC and CISC architectures and design issues
 
Dbms mini project
Dbms mini projectDbms mini project
Dbms mini project
 
IMPORTANCE OF COMMUNICATION IN PERSONAL AND PROFESSIONAL LIFE
IMPORTANCE OF COMMUNICATION IN PERSONAL AND PROFESSIONAL LIFEIMPORTANCE OF COMMUNICATION IN PERSONAL AND PROFESSIONAL LIFE
IMPORTANCE OF COMMUNICATION IN PERSONAL AND PROFESSIONAL LIFE
 
ACTIVITY BASED LEARNING THROUGH ONLINE COLLEGE
ACTIVITY BASED LEARNING THROUGH ONLINE COLLEGEACTIVITY BASED LEARNING THROUGH ONLINE COLLEGE
ACTIVITY BASED LEARNING THROUGH ONLINE COLLEGE
 
SMART WASTE MANAGEMENT AND RAINWATER HARVESTING
SMART WASTE MANAGEMENT AND RAINWATER HARVESTINGSMART WASTE MANAGEMENT AND RAINWATER HARVESTING
SMART WASTE MANAGEMENT AND RAINWATER HARVESTING
 
Rock , paper and scissors game made with PYTHON
Rock , paper and  scissors game made with PYTHON Rock , paper and  scissors game made with PYTHON
Rock , paper and scissors game made with PYTHON
 
Chemistry (biomass and recyclable polymers)
Chemistry (biomass and recyclable polymers)Chemistry (biomass and recyclable polymers)
Chemistry (biomass and recyclable polymers)
 
Basic electrical engineering (Autotransformer)
Basic electrical engineering (Autotransformer)Basic electrical engineering (Autotransformer)
Basic electrical engineering (Autotransformer)
 

Recently uploaded

Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
pritamlangde
 

Recently uploaded (20)

Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 

Polymorphism in Python

  • 2. INTRODUCTION • In programming, polymorphism means the same function name (but different signatures) being used for different types. • In Python, Polymorphism lets us define methods in the child class that have the same name as the methods in the parent class. In inheritance, the child class inherits the methods from the parent class. However, it is possible to modify a method in a child class that it has inherited from the parent class.
  • 3. Exampleof inbuilt polymorphic functions: • CODE:
  • 5. Polymorphism with class methods: • The below code shows how Python can use two different class types, in the same way. We create a for loop that iterates through a tuple of objects. Then call the methods without being concerned about which class type each object is. We assume that these methods actually exist in each class. • CODE:
  • 7. Polymorphismwith Inheritance: • In Python, Polymorphism lets us define methods in the child class that have the same name as the methods in the parent class. In inheritance, the child class inherits the methods from the parent class. However, it is possible to modify a method in a child class that it has inherited from the parent class. This is particularly useful in cases where the method inherited from the parent class doesn’t quite fit the child class. In such cases, we re- implement the method in the child class. This process of re-implementing method in the child class is known as Method Overriding.
  • 10. CONCLUSION •Polymorphism is a very important concept in Object- Oriented Programming. We can use the concept of polymorphism while creating class methods as Python allows different classes to have methods with the same name.