All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Share
Modified on
03 May 2023 07:28 pm
Skill-Lync
Object-Oriented Programming (OOP) is a programming paradigm that focuses on modelling software systems as collections of objects that have both data (attributes) and behaviour (methods). OOP is based on the idea of classes and objects.
An object is a real-world entity, such as a pen, chair, table, computer, watch, etc. Object-based Programming is a methodology using which we can design a program by using classes and objects. OOP design techniques simplify software development and its maintenance by providing the following concepts:
In this blog, let’s look at the concept of Polymorphism.
Polymorphism is one of the key principles of object-oriented programming, which allows objects of different classes to be treated as if they are of the same type. This means that a single interface can be used to represent different objects, and the behaviour of the objects can be changed at runtime.
The word “polymorphism” also signifies different forms. It is a very important concept in programming, referring to using a single type entity (method, function, operator or object) to represent different types in different scenarios.
Some examples of polymorphism in Python are described below:
In Python, the ‘+’ operator doesn’t just have a simple application. For integer data types, it is used for the addition of numbers, as shown below:
The output of the above program is 30
For string data types, the polymorphism method is used for the concatenation of strings, as shown below:
The output of the above program is “Skill-Lync”
As can be seen from the above two examples, the same “+” operator can be used differently for two different data types. This is the most simple occurrence of polymorphism in Python.
The example below applies the len () function to different data types. For different data types, the output is different.
The output for the above program is as follows:
The below example shows how Python uses two different types of classes in the same way. We create a “for” loop that iterates through a tuple of objects. We then call the methods regardless of which class type each object is. We assume that these methods actually exist in each class.
Program:
Output:
In Inheritance, property of the parent class is inherited in a child class. For example, in the Python program shown below three classes (Bird, sparrow and ostrich) are created. Bird is parent class and sparrow and ostrich are child classes. Child classes inherit all the properties of the parent class. Methods/functions written in a parent class also become a part of child classes or methods/functions written in a parent class belong to parent class. But the methods written in parent class can be modified in child class, if it does not fit the purpose. This process of re-implementing a method in the child class is known as method overriding.
Polymorphism can also be achieved using method overloading, a method with the same name but different input arguments. Method overloading is not possible in Python.
Polymorphism can be an incredibly useful technique for code management. Multiple developers can simultaneously work on code for any use case in the real world. It’s important to be clear about the structure of your code and make sure the hierarchy of functions used is clear.
Author
Navin Baskar
Author
Skill-Lync
Subscribe to Our Free Newsletter
Continue Reading
Related Blogs
Learn how to render a shock-tube-simulation and how to work on similar projects after enrolling into anyone of Skill-Lync's CAE courses.
10 May 2020
In this blog, read how to design the frontal BIW enclosure of a car (Bonnet) and learn how Skill-Lync Master's Program in Automotive Design using CATIA V5 will help you get employed as a design engineer.
10 May 2020
Tetrahedral is a four- nodded solid element that can be generated through the tria element by creating a volume and also through the existing volume of the geometry. These elements are used where the geometry has high thickness and complexity. The image attached below is a representation of a Tetra element. The Tetra element will have 4 triangular faces with four nodes joining them together
02 Aug 2022
A connector is a mechanism that specifies how an object (vertex, edge, or face) is connected to another object or the ground. By often simulating the desired behaviour without having to build the precise shape or specify contact circumstances, connectors make modeling simpler.
03 Aug 2022
One of the most crucial processes in carrying out an accurate simulation using FEA is meshing. A mesh is composed of elements that have nodes—coordinate positions in space that might change depending on the element type—that symbolise the geometry's shape.
04 Aug 2022
Author
Skill-Lync
Subscribe to Our Free Newsletter
Continue Reading
Related Blogs
Learn how to render a shock-tube-simulation and how to work on similar projects after enrolling into anyone of Skill-Lync's CAE courses.
10 May 2020
In this blog, read how to design the frontal BIW enclosure of a car (Bonnet) and learn how Skill-Lync Master's Program in Automotive Design using CATIA V5 will help you get employed as a design engineer.
10 May 2020
Tetrahedral is a four- nodded solid element that can be generated through the tria element by creating a volume and also through the existing volume of the geometry. These elements are used where the geometry has high thickness and complexity. The image attached below is a representation of a Tetra element. The Tetra element will have 4 triangular faces with four nodes joining them together
02 Aug 2022
A connector is a mechanism that specifies how an object (vertex, edge, or face) is connected to another object or the ground. By often simulating the desired behaviour without having to build the precise shape or specify contact circumstances, connectors make modeling simpler.
03 Aug 2022
One of the most crucial processes in carrying out an accurate simulation using FEA is meshing. A mesh is composed of elements that have nodes—coordinate positions in space that might change depending on the element type—that symbolise the geometry's shape.
04 Aug 2022
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.