SlideShare a Scribd company logo
1 of 19
Operators are functions that perform some
logical calculations.
Operators manipulate the value of the
operands.
Python supports several kinds of operators.
Arithmetic operators
Relational operators
Identity operators
Logical operators
Bitwise operators
Membership operators
Let us discuss one –by – one in detailed.
 Arithmetic operators are used with numeric
values to perform common mathematical
operations.
 Arithmetic operators are used for Addition,
subtraction, multiplication and division and so
on.
 Let us discuss them with an example.
Operator Description Example
Addition(+) Add values on either side of the operator A+B =9
Subtraction(-) Subtracts A from B A-B =3
Multiplication(*) Multiplies A with B A*B = 18
Division(/) Divides the denominator with numerator A/B =2
Modulus(%)
Performs the division operator and returns the
remainder
A%B=0
Exponent(**) Performs exponential calculation on operators
A**B= 6 power 3
=216
 These operator compares the operands and
displays the result.
 Let us assume a = 3 , b =5
Operator Description Example
Equal to (==) This operation returns true if two values are equal A==B returns False
Not equal to
(!=)
If the two operands are not equal this returns true A!=B returns true
Greater than
(>)
If the value of the left operand is greater than right this returns
true
A>B returns false
Less than (<)
This operator true if the left operand is less than the right
operand
A< B returns true
Greater than
or equal to
(>=)
This operator returns true if the left operand is greater than or
equal to the right operand
A>=B returns false
Less than or
equal to (<=)
This operator returns true if the left operand is less than or equal
to the right operand
A<=B returns True
 The Identity operators are used to check if both
the operands reference the same object
memory.
Operator Description Example
is
Returns true if both variables are the
same object
x is y
is not
Returns true if both variables are not
the same object
x is not y
The is not operator is opposite of is operator.
Let us take some examples
A = 10
B = 10
A is B #will return True because both are referencing the same
memory address.
A is not B #will return False because both are referencing the same
memory address.
 Logical operators are used for the logic
condition ( true (or) false).
 We have three types of logical operators.
Let a = 1, b = 2
Operator Example Meaning Result
And a and b If a is False returns
a
Otherwise returns b
2
Or A or b If a is false returns
b
Otherwise returns a
1
Not Not a If a is False returns
True
Otherwise returns
False
False
 Python Bitwise operators are used to perform
bit operations.
 All the decimal values will be converted into
binary values (sequence of bits i.e 0100, 1100,
1000, 1001 etc). Next, Python bitwise operators
will work on these bits such as shifting them
left to right or converting bit value from 0 to 1
etc.
 Let us discuss with an example A =30, B= 23
 These two numbers written in binary format as
 A = 30 = 0001 1110, B = 23 = 0001 0111.
Operator Description Example
And (&)
If both the inputs are True the result is True else the
result is False
A&B =22 (0001 0110)
Or(|)
If both the inputs are False the result is zero else the
result is True
A|B= 31(0001 1111)
Xor(^)
If both the bits are same the result is False else the
result is True
A^B =9(0000 1001)
Compliment(~) If the input is True the output is False and vice-versa A~B =-31(1000 1111)
 Membership operators are used to test if a sequence is
presented in an object.
 The membership operators are classified into two types.
 A={1 ,2,3,4,5}
Operator Description Example
Is
It returns true if the
value is found in the
sequence
5 in A returns True
10 in A returns False
Not in
True if the variable is
not found in the
sequence
5 not in A
returns False
10 not in
A returns True
 When there is several operations to be performed, operator precedence
determines which operator would be given importance over others.
 **
 ~+/~-
 */%//
 +-
 >><<
 &
 ^|
 <=< >>=
 <>==!=
 = -= +=//=%=/=*=*==
 Is, is not
 In in not
 Not or and
Python operators

More Related Content

What's hot (18)

Operators in c++
Operators in c++Operators in c++
Operators in c++
 
Operators
OperatorsOperators
Operators
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 
Operators
OperatorsOperators
Operators
 
Report on c
Report on cReport on c
Report on c
 
Relational operators
Relational operatorsRelational operators
Relational operators
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
 
Operators
OperatorsOperators
Operators
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Operators and it's type
Operators and it's type Operators and it's type
Operators and it's type
 

Similar to Python operators (20)

Opeartor &amp; expression
Opeartor &amp; expressionOpeartor &amp; expression
Opeartor &amp; expression
 
Operator 04 (js)
Operator 04 (js)Operator 04 (js)
Operator 04 (js)
 
java operators
 java operators java operators
java operators
 
C programming operators
C programming operatorsC programming operators
C programming operators
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
11operator in c#
11operator in c#11operator in c#
11operator in c#
 
Session03 operators
Session03 operatorsSession03 operators
Session03 operators
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Conditional and special operators
Conditional and special operatorsConditional and special operators
Conditional and special operators
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Bit shift operators
Bit shift operatorsBit shift operators
Bit shift operators
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
Python basic operators
Python   basic operatorsPython   basic operators
Python basic operators
 
Operators
OperatorsOperators
Operators
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 

More from nuripatidar

More from nuripatidar (9)

Python program
Python programPython program
Python program
 
Python lists
Python listsPython lists
Python lists
 
Tuple.py
Tuple.pyTuple.py
Tuple.py
 
Indian history
Indian historyIndian history
Indian history
 
Python basic Program
Python basic ProgramPython basic Program
Python basic Program
 
Python Programme list
Python Programme listPython Programme list
Python Programme list
 
Chemistry
ChemistryChemistry
Chemistry
 
Python statements
Python statementsPython statements
Python statements
 
Python data type
Python data typePython data type
Python data type
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

Python operators

  • 1.
  • 2.
  • 3. Operators are functions that perform some logical calculations. Operators manipulate the value of the operands. Python supports several kinds of operators.
  • 4. Arithmetic operators Relational operators Identity operators Logical operators Bitwise operators Membership operators
  • 5. Let us discuss one –by – one in detailed.
  • 6.  Arithmetic operators are used with numeric values to perform common mathematical operations.  Arithmetic operators are used for Addition, subtraction, multiplication and division and so on.  Let us discuss them with an example.
  • 7. Operator Description Example Addition(+) Add values on either side of the operator A+B =9 Subtraction(-) Subtracts A from B A-B =3 Multiplication(*) Multiplies A with B A*B = 18 Division(/) Divides the denominator with numerator A/B =2 Modulus(%) Performs the division operator and returns the remainder A%B=0 Exponent(**) Performs exponential calculation on operators A**B= 6 power 3 =216
  • 8.  These operator compares the operands and displays the result.
  • 9.  Let us assume a = 3 , b =5 Operator Description Example Equal to (==) This operation returns true if two values are equal A==B returns False Not equal to (!=) If the two operands are not equal this returns true A!=B returns true Greater than (>) If the value of the left operand is greater than right this returns true A>B returns false Less than (<) This operator true if the left operand is less than the right operand A< B returns true Greater than or equal to (>=) This operator returns true if the left operand is greater than or equal to the right operand A>=B returns false Less than or equal to (<=) This operator returns true if the left operand is less than or equal to the right operand A<=B returns True
  • 10.  The Identity operators are used to check if both the operands reference the same object memory. Operator Description Example is Returns true if both variables are the same object x is y is not Returns true if both variables are not the same object x is not y The is not operator is opposite of is operator.
  • 11. Let us take some examples A = 10 B = 10 A is B #will return True because both are referencing the same memory address. A is not B #will return False because both are referencing the same memory address.
  • 12.  Logical operators are used for the logic condition ( true (or) false).  We have three types of logical operators.
  • 13. Let a = 1, b = 2 Operator Example Meaning Result And a and b If a is False returns a Otherwise returns b 2 Or A or b If a is false returns b Otherwise returns a 1 Not Not a If a is False returns True Otherwise returns False False
  • 14.  Python Bitwise operators are used to perform bit operations.  All the decimal values will be converted into binary values (sequence of bits i.e 0100, 1100, 1000, 1001 etc). Next, Python bitwise operators will work on these bits such as shifting them left to right or converting bit value from 0 to 1 etc.
  • 15.  Let us discuss with an example A =30, B= 23  These two numbers written in binary format as  A = 30 = 0001 1110, B = 23 = 0001 0111. Operator Description Example And (&) If both the inputs are True the result is True else the result is False A&B =22 (0001 0110) Or(|) If both the inputs are False the result is zero else the result is True A|B= 31(0001 1111) Xor(^) If both the bits are same the result is False else the result is True A^B =9(0000 1001) Compliment(~) If the input is True the output is False and vice-versa A~B =-31(1000 1111)
  • 16.  Membership operators are used to test if a sequence is presented in an object.
  • 17.  The membership operators are classified into two types.  A={1 ,2,3,4,5} Operator Description Example Is It returns true if the value is found in the sequence 5 in A returns True 10 in A returns False Not in True if the variable is not found in the sequence 5 not in A returns False 10 not in A returns True
  • 18.  When there is several operations to be performed, operator precedence determines which operator would be given importance over others.  **  ~+/~-  */%//  +-  >><<  &  ^|  <=< >>=  <>==!=  = -= +=//=%=/=*=*==  Is, is not  In in not  Not or and