SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
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 (20)

PPSX
Modules and packages in python
TMARAGATHAM
 
PPTX
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
PPTX
Python: Polymorphism
Damian T. Gordon
 
PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
PPTX
Python-DataAbstarction.pptx
Karudaiyar Ganapathy
 
PPTX
Packages In Python Tutorial
Simplilearn
 
PPTX
CLASS OBJECT AND INHERITANCE IN PYTHON
Lalitkumar_98
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
Class, object and inheritance in python
Santosh Verma
 
PDF
Python Programming - VI. Classes and Objects
Ranel Padon
 
PPTX
Functions in Python
Kamal Acharya
 
PDF
Strings in python
Prabhakaran V M
 
PPS
Wrapper class
kamal kotecha
 
PPTX
Modules in Python Programming
sambitmandal
 
PPSX
python Function
Ronak Rathi
 
PPTX
Python: Modules and Packages
Damian T. Gordon
 
PPTX
PYTHON PPT.pptx
AbhishekMourya36
 
PPTX
OOPS Basics With Example
Thooyavan Venkatachalam
 
PDF
Java Thread Synchronization
Benj Del Mundo
 
Modules and packages in python
TMARAGATHAM
 
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
Python: Polymorphism
Damian T. Gordon
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Python-DataAbstarction.pptx
Karudaiyar Ganapathy
 
Packages In Python Tutorial
Simplilearn
 
CLASS OBJECT AND INHERITANCE IN PYTHON
Lalitkumar_98
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Class, object and inheritance in python
Santosh Verma
 
Python Programming - VI. Classes and Objects
Ranel Padon
 
Functions in Python
Kamal Acharya
 
Strings in python
Prabhakaran V M
 
Wrapper class
kamal kotecha
 
Modules in Python Programming
sambitmandal
 
python Function
Ronak Rathi
 
Python: Modules and Packages
Damian T. Gordon
 
PYTHON PPT.pptx
AbhishekMourya36
 
OOPS Basics With Example
Thooyavan Venkatachalam
 
Java Thread Synchronization
Benj Del Mundo
 

Similar to Polymorphism in Python (20)

PPTX
polymorphismppt for Computer Applications-211218133624.pptx
waarrior1234567
 
PPTX
Python-Polymorphism.pptx
Karudaiyar Ganapathy
 
PPTX
arthimetic operator,classes,objects,instant
ssuser77162c
 
PDF
Learn Polymorphism in Python with Examples.pdf
Datacademy.ai
 
PPTX
Polymorphism.pptx
TuanMinhHuynh3
 
PPTX
OOPS (Object Oriented Programming System) CONCEPTS
HariShiva7
 
PPTX
28c
Sireesh K
 
PPTX
28csharp
Sireesh K
 
PPTX
Object Oriented Programming.pptx
SAICHARANREDDYN
 
PDF
Object-Oriented Programming System presentation
PavanKumarPathipati
 
PDF
‏‏‏‏‏‏oop lecture objectives will come.pdf
nabeehmohammedtaher
 
PPTX
Introduction to Object Oriented Programming in Python.pptx
eduardocehenmu
 
PPTX
Class and Objects in python programming.pptx
Rajtherock
 
PDF
Java programming -Object-Oriented Thinking- Inheritance
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Object oriented programming
Nadeesha Thilakarathne
 
PPTX
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
DOC
Questpond - Top 10 Interview Questions and Answers on OOPS
gdrealspace
 
PDF
javainheritance
Arjun Shanka
 
PDF
Method overloading and method overriding
RomitRajSingh1
 
polymorphismppt for Computer Applications-211218133624.pptx
waarrior1234567
 
Python-Polymorphism.pptx
Karudaiyar Ganapathy
 
arthimetic operator,classes,objects,instant
ssuser77162c
 
Learn Polymorphism in Python with Examples.pdf
Datacademy.ai
 
Polymorphism.pptx
TuanMinhHuynh3
 
OOPS (Object Oriented Programming System) CONCEPTS
HariShiva7
 
28csharp
Sireesh K
 
Object Oriented Programming.pptx
SAICHARANREDDYN
 
Object-Oriented Programming System presentation
PavanKumarPathipati
 
‏‏‏‏‏‏oop lecture objectives will come.pdf
nabeehmohammedtaher
 
Introduction to Object Oriented Programming in Python.pptx
eduardocehenmu
 
Class and Objects in python programming.pptx
Rajtherock
 
Java programming -Object-Oriented Thinking- Inheritance
Jyothishmathi Institute of Technology and Science Karimnagar
 
Object oriented programming
Nadeesha Thilakarathne
 
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
Questpond - Top 10 Interview Questions and Answers on OOPS
gdrealspace
 
javainheritance
Arjun Shanka
 
Method overloading and method overriding
RomitRajSingh1
 
Ad

More from Home (20)

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

Recently uploaded (20)

PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Distribution reservoir and service storage pptx
dhanashree78
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 

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.