Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Python Fundamentals

fundamental
Copyright
© © All Rights Reserved
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Python Fundamentals

fundamental
Copyright
© © All Rights Reserved
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 73

Designing an Interacting Website

using
Python-Django
@SSMRV
26th and 27th April 2022
What is Python?

Python is a high-level general purpose
programming language

Developed by Guido van Rossum in
1991

The language has object-oriented
programming constructs

Python is dynamically typed and
manages memory functionalities using
private help containers

It also supports procedural, functional programming tasks

Python has access to comprehensive libraries and
standard tools for software development and is known as
a maintained language.

The language can be used on many operating systems for
frontend and backend web development and was last updated
to series 3.0 in 2008
Examples of imperative languages are Pascal, C, Java, etc.
Examples of declarative languages are ML, pure Lisp and pure Prolog.

The programming model in imperative languages is based on a statement-at-a-time


paradigm where each statement has some effect on a memory store.
What is Python used for?

Python emphazies both object-oriented and structured
programming.

The language allows users to develop websites, use data science
and script programs.

Some examples of usages are:
– Custom Python GUI :

Python is used to develop websites using web frameworks such as
Django or Flask.

These frameworks help programmers create back-end server side
code in python.

Tkinter package is used to develop GUI

GUI applications are visual indicators used to navigate a device and
access software

Python allows custom GUI applications to be developed in accelerated
time using a few GUI frameworks such as Tk, wxPython, PyForms
– Data Model in Python

Is used to develop database models and technologies

Machine learning implements output algorithms that detect
input data patterns of quieries.

Python data modelling inherits classes and model classes for
database tables and maps

Python programming language can be developed to provide
SQL and Tableau like charts and graphs.

Integrating business intelligence software enables a company
to determine trends and patterns for predictive analysis reports
and data visualizations.
– Python Game Development:

Game development uses Python to scripts small codes that
automate tasks in gaming like accumulation of points, dashboard
plotting.

It is easy to create entire video games using this language

Python’s framework provides gaming development for Windows,
Mac, Linux, iOS and Android platforms

Python is used to provide add-ons game functionality, creae 3D
graphics and script various parts of the games.
– Regression in Python:

Most common usage of python is modelling for regression
testing and analytics.

Python can be used for machine learning algorithms to ensure
that variable data sets produce certain results.

This is achieved through linear regression or multi-linear
regression.

Using regression for data modelling is one of the most
powerful techniques used to make better investment decision
in business
– Loops in Python:

Python provides ease to software developers by enabling loop
sequencing to code.

The programming language enables users to create a
statement that repeats itself a certain number of times.

When making these statements, strings, arrays, lists, tuples,
and dict can be used in a loop with Python.

There are two looping statements used in Python- "Python ‘for'
loop" and the "Python ‘while' loop

Looping statements in Python are event-controlled responses
a programmer uses to communicate conclusive information.
Why Python?

Python is Easy to Learn and Use

Python is Handy for Web Development Purposes [Django, CherryPy, Grok, Flask,
Web2Py, etc.,]

The Language is Extensively used in Data Science

Has Multiple Libraries and Frameworks [NumPy, Matplotlib,SciPy, Django, BeautifulSoup,
etc., ]

Python can be used in ML tool [Pandas, NumPy, SciKit, TensorFlow, Keras, NLTK,
etc.,]

Python for Academics [use cases in data science, artificial intelligence, deep learning, and
others]

Has a Highly Supportive Community

Flexibility and Reliability

Free & Open Source
Python Installation on Ubuntu

Open the terminal : Ctrl+ Alt+ T

Update APT package -
– $ sudo apt-get update
– $ sudo apt install software-properties-common

Install Python
– $ sudo apt install python3.9

Verify Python Installation
– $ python3.9 --version
Python Quickstart

Python is an interpreted programming language

The developer writes the python program (.py)
files in a text editor and then put those files into
the python interpreter to be executed.

To execute the python program file
– $ python hello.py
Variable:

Variable is a storage location paired with an associated symbolic name, which contains some known or unknown quantity of information referred
to as a value

Variables are nothing but Reserved Memory Locations to store values.

Python considers values as object
Usage:
• No Declaration,
• Create variable by assigning value and
• Use that variable later in the program
Assignment statement:
• Stores a value into a variable.
Syntax:
• name = value
Examples:
• a = 15
• b = 3.5
• c = a+b
15 3.5 18.5
1221454 3222478 100222478
a b c
Addition of Two Numbers
// Simple C Program to Display “Addition of Two // Simple C++ Program to Display “Addition of /* Simple Java Program to Display “Addition of Two
Numbers" */
Numbers" // Two Numbers"

public class Hello


#include <stdio.h> #include<iostream>
{
int main() using namespace std; public static void main(String[] args)
{ int main() {
int a = 5; { int a = 5;
int b = 6; int a = 5; int b = 6;
int sum; int b = 6; int sum ;
sum = a+b; int sum; sum = a+b;
printf(“The addition is %d!“, sum); sum = a+b; System.out.println("Addition is
"+sum);
return 0; cout<<"Addition is " << sum; }
} return 0; }
}

Filename: Hello.c Filename: Hello.cpp Filename: Hello.java


// Simple C Program to Display “Addition of Two
Numbers"
int a = 5;
#include <stdio.h>
int main()
{
int a = 5;
int b = 6;
int sum;
sum = a+b;
printf(“The addition is %d!“, sum);
return 0;
}

Filename: Hello.c
// Simple C Program to Display “Addition of Two
Numbers"
int a = 5;
#include <stdio.h>
int main()
{ Dataty Value
pe
int a = 5;
int b = 6;
int sum;
sum = a+b;
printf(“The addition is %d!“, sum); Variable_na
me
return 0;
}

Filename: Hello.c
// Simple C Program to Display “Addition of Two
Numbers"
int a = 5; int b = 6; int sum;
#include <stdio.h>
int main() a b sum
{
int a = 5;
5 6
int b = 6; 12214 12214 12216
int sum; 54 78 82
sum = a+b;
printf(“The addition is %d!“, sum);
return 0;
}

Filename: Hello.c
// Simple C Program to Display “Addition of Two
Numbers"
int a = 5; int b = 6; int sum;
#include <stdio.h>
int main() a b sum
{
int a = 5;
5 + 6 = 11
int b = 6; 1221454 1221478 1221682
int sum;
sum = a+b;
printf(“The addition is %d!“, sum);
return 0;
}

Filename: Hello.c
Rules for framing a variable:

A variable name cannot start with a number


1

No special symbols are allowed in the middle of variable except underscore


2

Variable name may consist of letters, numbers and underscores


3

No Reserved words
4

Variable names are Case-Sensitive


5

6 Python has no command for declaring a variable.

No space are allowed in variable declaration


7
Multiple Assignment of Values

Example 1 >>> a = b = c = 1

Example 2 >>> a, b = 2 , 3

Example 3 >>> a, b, c = 2, 3.5, “Bangalore”

Example 4 >>> a, b = b, a
Python input()
input():

input() reads a value from user input.

input() is a built-in Python function which prompts user to enter some text input.

If we call input(), the program will stop at that point and waits until user inputs some information.

Program will resume once the user presses ENTER key

input() always read the string data
Syntax:

input([Optional])
Example:
age = input("How old are you? ")
print ("Your age is", age)
print ("You have", 65 - age, "years until retirement“)
Command Line Arguments:

Python also supports command line arguments which we can pass during run time

sys module is used for passing the command line arguments
Operators

Python operator is a symbol that performs an operation on one or more operands.

An operand is a variable or a value on which we perform the operation.

The standard mathematical operators that you are familiar with work the same way in Python as in
most other languages.

Python Operator falls into 7 categories

Python language supports the following types of operators.

Arithmetic Operators (+ - * / // % **)

Comparison (Relational) Operators (> < == <= >= != )

Assignment Operators (= += -= /= *= //= **=)

Logical Operators (and or not)

Bitwise Operators ( & | ^ << >> ~)

Membership Operators ( in not in)

Identity Operators (is is not)
Expressions and Statements

An expression is a combination of values, variables, and operators.


>>> 1+1 Composition
>>> a, b = 10, 5.3
2 >>>c = a*60+5.3

>>> x = 5
>>> x+5
>>>6+4/4*10/5
10

Order of operations: PEMDAS


Parentheses

Exponentiation

Multiplication and Division


Addition and Substraction (Operators with the same precedence are evaluated from left to right)

Comments
Indentation

Most languages don’t care about indentation

Most humans do

We tend to group similar things together

/* C Code */

If (foo) {
If (bar) {
baz(foo, bar);
}
else {
qux();
} }
Basic Statements: The If Statement (1)
If statements have the following basic structure:
# inside the interpreter # inside a script
>>> if condition: if condition:
... action .. action
Subsequent indented lines are assumed to be part of the if statement. The same is true for most other types of python statements.
A statement typed into an interpreter ends once an empty line is entered, and a statement in a script ends once an unindented line
appears. The same is true for defining functions.
If statements can be combined with else if (elif) and else statements as follows:
if condition1: # if condition1 is true, execute action1
action1
elif condition2: # if condition1 is not true, but condition2 is, execute
action2 # action2
else: # if neither condition1 nor condition2 is true, execute
action3 # action3
Conti...
Nested if Statement
If statment
Syntax:
Syntax: if expression:
if expression: statement(s)
elif expression:
statement(s)
statement(s)
else:
statement(s)

Example:
num = 3 Example:
num = 75
if num > 0:
if num >100:
print(num, "is a positive number.")
print(num, "is a greater than 100")
print("This is always printed.") elif num < 50:
num = -1 print(num, “less than 50”)
if num > 0: else:
print(num, "is a positive number.") print (num,”less than 50 )

print("This is also always printed.") print("This is also always printed.")


Basic Statements: The While Statement (1)

While statements have the following basic structure:

# inside the interpreter # inside a script


>>> while condition: while condition:
... action action
...

As long as the condition is true, the while statement will execute the action
Example:
>>> x = 1
>>> while x < 4: # as long as x < 4...
... print x**2 # print the square of x
... x = x+1 # increment x by +1
...
1 # only the squares of 1, 2, and 3 are printed, because
4 # once x = 4, the condition is false
9
>>>
Continuation (\)
Python statements are in general, delimited by NEWLINEs, meaning one statement per line.

Single statements can be broken up into multiple lines by use of the backslash.


The backslash symbol ( \ ) can be placed before a NEWLINE to continue the current
statement onto the next line.
Example:
# check conditions
If (weather_is_hot == 1) and \
(shark_warnings == 0):
send_goto_beach_mesg_to_pager()
Multiple Statements Groups as Suites (:)


Groups of individual statements making up a single code block are called
"suites" in Python.

Compound or complex statements, such as if , while , def , and class , are
those that require a header line and a suite.

We will refer to the combination of a header line and a suite as a clause.
Examples:

➢If condition :
pass
➢ While condition:
pass
➢ def name() :
pass
Multiple Statements on a Single Line ( ; )


The semicolon ( ; ) allows multiple statements on a single line given that neither statement
starts a new code block.

Example:

import sys; x = 'foo'; sys.stdout.write(x + '\n')


Variable Assignment

Assignment Operator (=)

Example:

A = 10
B = “RVCE”
C= A=A+1
C = (A = A + 1) <--- Error (Its Not Expression

Augmented Assignment
Beginning in Python 2.0, the equal sign can be combined with an arithmetic operation and the resulting value reassigned to the existing
variable. Known as augmented assignment, statements

Example:

x = x + 1 ==> x += 1
+= -= <<= >>= *= &= /= ^= |= %= **=
Python Identifiers

A Python identifier is a name used to identify a
➢ Variables,
➢ Functions,
➢ Class,
➢ Modules or
➢ Other object.

An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters,
underscores and digits (0 to 9).

Python does not allow punctuation characters such as @, $, and % within identifiers.

Python is a case sensitive programming language.

Thus, RVCE and rvce are two different identifiers in Python.
➢ First character must be a letter or underscore ( _ )
➢ Any additional characters can be alphanumeric or underscore
➢ Case-sensitive
Data Types
Data Types


Data type determines the set of values that a data item can take and the operations that can be performed on the item.

Python language provides Six basic data types.

List

Numbers Tuple Dictionary String

Sets
1. Numbers

A particular kind of data item, as defined by the values it can take, the programming language used, or the operations that can be performed
on it


Number data types store numeric values.


They are immutable data types


Example: Var = 1

Var = 2

Python supports four different numerical types



int


long


float


complex
Cont... (numbers)
int long float complex

10 519266L 0.0 5.24j

100 -0x313L 3.5 3.14j

-786 01254L -6.9 9.322ej

0 0xDEFABCCEDL 54+e52 0.875j

Number Type Conversion:


Type int(x) :convert x to a plain integer.

Type long(x) :convert x to a long integer.

Type float(x) :convert x to a floating-point number.

Type complex(x) :convert x to a complex number with real part x and imaginary part zero.

Type complex(x, y) :convert x and y to a complex number with real part x and imaginary part y. x and y are numeric expressions

Mathematical Functions:
abs(x), random.random(), log(x) , choice(seq), etc........
2. String

Strings are enclosed in single or double quotation marks

Double quotation marks allow the user to extend strings over multiple lines
without backslashes, which usually signal the continuation of an expression

Examples: 'abc', “ABC”, “””ABC”””
Concatenation and repetition
Strings are concatenated with the + sign:
>>> 'abc'+'def'
'abcdef'
Strings are repeated with the * sign:
>>> 'abc'*3
'abcabcabc'
String Operatons

>>>print ("IoT workshop jointly organised by %s and %s !" % ('RVCE', ‘CISCO’))


Output:
IoT workshop jointly organised by RVCE and CISCO !
$GPRMC,235316.000,A,4003.9040,N,10512.5792,W,0.09,144.75,141112,,*19

>>>s = “GPRMC,235316.000,A,4003.9040,N,10512.5792,W,0.09,144.75,141112,,*19”

>>>a, b = s[19:28], s[31:41]


>>>a, b

output:
('4003.9040', '10512.5792')

>>>a=float(a), b=float(b)
Output:
(4003.904, 10512.5792)
3. Lists:
Basic properties:

Lists are contained in square brackets []

Lists can contain numbers, strings, nested sublists, or nothing
Examples:
L1 = [0,1,2,3]

L2 = ['zero', 'one']

L3 = [0,1,[2,3],'three',['four,one']]

L4 = []


List indexing works just like string indexing

Lists are mutable: individual elements can be reassigned in place. Moreover, they can grow and shrink in
place

Example:
>>> L1 = [0,1,2,3]
>>> L1[0] = 4
>>> L1[0]
4
List Operations

Some basic operations on lists:



Indexing: L1[i], L2[i][j]

Slicing: L3[i:j]

L1.append(x)

L1.sort()
4. Tuple:
Basic properties:
Tuples are contained in parentheses ()

Tuples can contain numbers, strings, nested sub-tuples, or nothing


Examples:

t1 = (0,1,2,3),

t2 = ('zero', 'one'),

t3 = (0,1,(2,3),'three',('four,one')),
t4 = ()

As long as you're not nesting tuples, you can omit the parentheses

Example: t1 = 0,1,2,3 is the same as t1 = (0,1,2,3)


Tuple indexing works just like string and list indexing

Tuples are immutable: individual elements cannot be reassigned in place.


Concatenation:

>>> t1 = (0,1,2,3); t2 = (4,5,6)


>>> t1+t2
(0,1,2,3,4,5,6)
Repetition:

>>> t1*2
(0,1,2,3,0,1,2,3)
Length: len(t1) (this also works for lists and strings)

Tuple:

tup1 = ('RVCE', 'Workshop', 2021, 2022)


tup2 = (1, 2, 3, 4, 5, 6, 7 )
print "tup1[0]: ", tup1[0]
print "tup2[1:5]: ", tup2[1:5]
5. Dictionary:


Each key is separated from its value by a colon (:), the items are separated by commas, and
the whole thing is enclosed in curly braces.
Empty dictionary = {}

Keys are unique within a dictionary while values may not be.


The values of a dictionary can be of any type, but the keys must be of an immutable data
type such as strings, numbers, or tuples.
Example:

dict = {'College': 'RVCE', 'Workshop': ‘IoT’, 'Place': 'Bangalore', ‘Date’:17}


Dictionary Operations:
6. Sets:

Sets are used to store multiple items in a single variable.

A set is a collection which is both unordered and unindexed.

Sets are written with curly brackets.

An empty set is created as “a = set{}”

Sets are unordered.

Set elements are unique.
Duplicate elements are not allowed.


A set itself may be modified, but the elements contained in the set must be of an
immutable type.
Example:

a = {1, 2, 3, 5, 6, 'RVCE'}
Operation on Sets

Operation Notation Methods in Python Meaning


Intersection
A ∩B A.intersection(B) All elements which are both in
A and B

Union A U B A.union(B) All elements which are in


either A or B

Difference A-B A.difference(B) All elements which are in A but


not in B
Functions

Set of statements to perform specfic task.
Built-in fuctions Our Own functions

Built-in functions

<<function_name>>(<<arg>>)
abs(), round(value,[No.places]), pow(val1,val2,[val3])

round(3.4) round(3.6) round(5.31243,2)
3 4 5.31

Pow(2,3) pow(2,3,3)
8 2 (8%3)
help(built_in func) id(object) hex(decimal) oct(decimal)
A=9, B=9, id(A), id(B), id(9) output: Same id
Note: Objects with same value refers to same memory
Our Own Functions

Functions as object

Provides modularity and reusability

Syntax
def functionname( parameters ):
"Document string" >>> id(print_hello)
Statements 139710611025432
return [expression] >>> type(print_hello)
<class 'function'>
>>> def print_hello(str1,str2):
"demo of my own function"
print(str1,str2)

>>> print_hello("hello","how r
u")
hello how r u
Parameter Passing >>> def argdemo(nlist):

Pass by Reference by default nlist.append(['r','v','c','e'])
print("LIST INSIDE",nlist)
Return

>>> nlist=[1,2,3]
>>> nlist
[1, 2, 3]
>>> argdemo(nlist)
LIST INSIDE [1, 2, 3, ['r', 'v', 'c',
'e']]
>>> nlist
[1, 2, 3, ['r', 'v', 'c', 'e']]
Types of parameter passing

Function can take four different types of arguments

Required arguments
Keyword arguments
Default argumets
Variable length argumets
Required Arguments
Arguments must be passed in correct number and order during function call

def requiredArg (str,num):

requiredArg ("Hello",12) \\ function call


def lsearch(a,n):
p=-1
for i in range(0,len(a)): >>> a=[20,10,100,4,6]
if a[i]==n: >>> lsearch(a,4)
p=i Element found at 4
break >>> lsearch(a,80)
if p>-1:
print("Element found at",p+1)
Element not found
else:
print("Element not found")
return
Keyword Arguments
Arguments can be passed in any order during function call

keywords provided to match the values with parameters

def concat(b,a):
print ("Message from the function\n")
c=a+b
print (c)
concat(a="MCA ",b= "2")
Default Arguments
Arguments will take the default value if no argument value is passed during function call

def defaultargument(a, b = 24):


print ("Message from the function Default Arguments\n")
print ("Name ==> ", a)
print ("Age ===> ", b)

defaultargument(a="Miki",b= "26")
defaultargument(a="Miki")
Variable number of Arguments
Variable number of arguments can be passed based on requirement during function call

def printinfo( arg1, *vartuple ):


"This prints a variable passed arguments"
print ("Output is: ")
print (arg1)
for var2 in vartuple:
print (var2, vartuple)
return

# Now you can call printinfo function


printinfo( 10 )
printinfo( 70, 60, 50 )
printinfo( 70, 60, 50, 40, 30, 20, 10, -1 )
Procedural Language .vs. Object Oriented Programming Langauage


Procedural language is based on functions but object oriented language is based on real
world objects.

Procedural language gives importance on the sequence of function execution but object
oriented language gives importance on states and behaviors of the objects.

Procedural language exposes the data to the entire program but object oriented language
encapsulates the data.

Procedural language follows top down programming paradigm but object oriented
language follows bottom up programming paradigm.

Procedural language is complex in nature so it is difficult to modify, extend and maintain
but object oriented language is less complex in nature so it is easier to modify, extend and
maintain.

Procedural language provides less scope of code reuse but object oriented language provides
more scope of code reuse.
Encapsulation

Encapsulation is one of the fundamental concepts in object-oriented
programming (OOP)

It describes the idea of wrapping data and the methods that work on
data within one unit

This puts restrictions on accessing variables and methods directly
and can prevent the accidental modification of data.

To prevent accidental change, an object’s variable can only be
changed by an object’s method.

Those types of variables are known as private
Variable

A class is an example of encapsulation as it
encapsulates all the data that is member
functions, variables, etc.

Methods Variables

Class
Class


A class is a user-defined blueprint or prototype from which objects are
created.

Classes provide a means of bundling data and functionality together.

Creating a new class creates a new type of object, allowing new
instances of that type to be made.

Each class instance can have attributes attached to it for maintaining
its state.

Class instances can also have methods (defined by their class) for
modifying their state
Class members
(Data member and Member function)
Data Members:

Variables defined in a class are called data memebers.

There are 2 types of variables: Class Variables and Instance Variables
– Class variable:

The variables accessed by all the objects(instances) of a class are called class variables.

There is only copy of the class variable and when any one object makes a change to a class variable, the
change is reflected in all the other instances as well.

Class variables can be accessed using the syntax
– Class_name.Class variable
– Object_name. Class variable
– Object/instance Variable:

Variables owned by each individual object (instance of a class) are called object variables.

Each object has its own copy of the field i.e. they are not shared and are not related in any way to the
field by the same name in a different instance of the same class.

Note: if user changes the value of class variable using class name, then it reflects
to all objects if user changes the value of class variable using object name, then it
reflects only to that objects
Member Function(method)
Member function(method):

A method is a function that is defined inside a class.

Methods are members of classes.

A method is a function that is available for a given object.

There are different types of methods like
– Class methods,
– Instance methods,
– Service methods, and
– Support methods.
Class method:

A "class method" is a method where the initial parameter is not an instance object(self), but the class object , which by
convention is called cls .

This is implemented with the @classmethod decorator.

The class method does not require object to invoke it.
Instance Method:

An "Instance method" is a method where the initial parameter is an instance of object(self) and requires no decorator.

These are the most common methods used.
Object

An Object is an instance of a Class.

An object consists of :
– State: It is represented by the attributes of an object. It also
reflects the properties of an object.
– Behavior: It is represented by the methods of an object. It
also reflects the response of an object to other objects.
– Identity: It gives a unique name to an object and enables
one object to interact with other objects.

Identify: name of the pen

State/Attributes: color, height, type


Behaviour: weight, volume calculation , etc. ,
The self

Class methods must have an extra first
parameter in the method definition.

We do not give a value for this parameter
when we call the method, Python provides it.

If we have a method that takes no arguments,
then we still have to have one argument.
__init__ method

The __init__ method is the constructor that is used to
initializing the object’s state.

A constructor also contains a collection of statements(i.e.
instructions) that are executed at the time of Object
creation.

It runs as soon as an object of a class is instantiated.

The method is useful to do any initialization you want to do
with your object
Inheritance
Inheritance

Inheritance is the ability to define a new class which is a modified version of an existing class.

The primary advantage of this feature is that you can add new methods to a class without modifying the existing class.

The existing class is called as Super Class/Parent class.

A Subclass, "derived class", their class, or child class is a derivative class which inherits the properties (methods and attributes) from one are
more super classes.

Inheritance is a powerful feature of Object Oriented Programming.

Inheritance can facilitate code reuse, since you can customize the behavior of parent classes without having to modify them.

Disadvantage of inheritance is that it make programs difficult to read.

When a method is invoked, it is sometimes not clear where to find its definition.

The relevant code may be scattered among several modules.

In Inheritance base class and child classes are tightly coupled. Hence If you change the code of parent class, it will get affects to the all the child
classes.
Polymorphism
Polymorphism

The word polymorphism means having many forms. In simple words, we can define polymorphism as the
ability of a message to be displayed in more than one form.

A language that features polymorphism allows developers to program in the general rather than program in
the specific.

In a programming language that exhibits polymorphism, objects of classes belonging to the same
hierarchical tree (inherited from a common base class) may possess functions bearing the same name, but
each having different behaviors

Polymorphism is mainly divided into two types:
– Static or Compile Time Polymorphism

Operator Overloading

Function Overloading
– Dynamic or Runtime Polymorphism
Polymorphism

Association of method call to the method body is known as binding.

There are two types of binding:
– Static Binding that happens at compile time

Examples:
– Operator Overloading
– Function Overloading
– Dynamic Binding that happens at runtime.

Example:
– Method Overriding
Method overriding

Method overriding is an ability of any object-oriented programming language that allows a subclass or child
class to provide a specific implementation of a method that is already provided by one of its super-classes or
parent classes.

When a method in a subclass has the same name, same parameters or signature and same return type(or sub-
type) as a method in its super-class, then the method in the subclass is said to override the method in the super-
class.

You might also like