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 inbuiltpolymorphic functions:
• CODE:
• OUTPUT:
Polymorphismwithclassmethods:
• 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:
PolymorphismwithInheritance:
• 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

Similar to polymorphismppt for Computer Applications-211218133624.pptx

P.7 media 2 polymorphism
P.7 media 2 polymorphismP.7 media 2 polymorphism
P.7 media 2 polymorphism
ahmadmuzaqqi
 

Similar to polymorphismppt for Computer Applications-211218133624.pptx (20)

Java
JavaJava
Java
 
P.7 media 2 polymorphism
P.7 media 2 polymorphismP.7 media 2 polymorphism
P.7 media 2 polymorphism
 
Python_Unit_3.pdf
Python_Unit_3.pdfPython_Unit_3.pdf
Python_Unit_3.pdf
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java
 
PythonOO.pdf oo Object Oriented programming
PythonOO.pdf oo Object Oriented programmingPythonOO.pdf oo Object Oriented programming
PythonOO.pdf oo Object Oriented programming
 
javainheritance
javainheritancejavainheritance
javainheritance
 
Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
 
Object Oriented Programming.pptx
 Object Oriented Programming.pptx Object Oriented Programming.pptx
Object Oriented Programming.pptx
 
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)
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
 
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
 
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
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 

More from waarrior1234567

microsoft-surface for engineers-8864-sNojnaw.pptx
microsoft-surface for engineers-8864-sNojnaw.pptxmicrosoft-surface for engineers-8864-sNojnaw.pptx
microsoft-surface for engineers-8864-sNojnaw.pptx
waarrior1234567
 
iotsensordevices-romanstaszewski-20160830-160831072812.pptx
iotsensordevices-romanstaszewski-20160830-160831072812.pptxiotsensordevices-romanstaszewski-20160830-160831072812.pptx
iotsensordevices-romanstaszewski-20160830-160831072812.pptx
waarrior1234567
 
presentationonthetopiconinputandoutputdevice-200424103640 (1).pdf
presentationonthetopiconinputandoutputdevice-200424103640 (1).pdfpresentationonthetopiconinputandoutputdevice-200424103640 (1).pdf
presentationonthetopiconinputandoutputdevice-200424103640 (1).pdf
waarrior1234567
 
Presentation of data communication.pptx
Presentation of data  communication.pptxPresentation of data  communication.pptx
Presentation of data communication.pptx
waarrior1234567
 
Companies_list job fair in mewar University pdf
Companies_list job fair in mewar University pdfCompanies_list job fair in mewar University pdf
Companies_list job fair in mewar University pdf
waarrior1234567
 
Features Of OOPS and characteristics.pptx
Features Of OOPS and characteristics.pptxFeatures Of OOPS and characteristics.pptx
Features Of OOPS and characteristics.pptx
waarrior1234567
 

More from waarrior1234567 (6)

microsoft-surface for engineers-8864-sNojnaw.pptx
microsoft-surface for engineers-8864-sNojnaw.pptxmicrosoft-surface for engineers-8864-sNojnaw.pptx
microsoft-surface for engineers-8864-sNojnaw.pptx
 
iotsensordevices-romanstaszewski-20160830-160831072812.pptx
iotsensordevices-romanstaszewski-20160830-160831072812.pptxiotsensordevices-romanstaszewski-20160830-160831072812.pptx
iotsensordevices-romanstaszewski-20160830-160831072812.pptx
 
presentationonthetopiconinputandoutputdevice-200424103640 (1).pdf
presentationonthetopiconinputandoutputdevice-200424103640 (1).pdfpresentationonthetopiconinputandoutputdevice-200424103640 (1).pdf
presentationonthetopiconinputandoutputdevice-200424103640 (1).pdf
 
Presentation of data communication.pptx
Presentation of data  communication.pptxPresentation of data  communication.pptx
Presentation of data communication.pptx
 
Companies_list job fair in mewar University pdf
Companies_list job fair in mewar University pdfCompanies_list job fair in mewar University pdf
Companies_list job fair in mewar University pdf
 
Features Of OOPS and characteristics.pptx
Features Of OOPS and characteristics.pptxFeatures Of OOPS and characteristics.pptx
Features Of OOPS and characteristics.pptx
 

Recently uploaded

Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
Kira Dess
 
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
AshwaniAnuragi1
 

Recently uploaded (20)

Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/Footing
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
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)
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdf
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
 

polymorphismppt for Computer Applications-211218133624.pptx

  • 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.
  • 5. Polymorphismwithclassmethods: • 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. PolymorphismwithInheritance: • 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.