SlideShare a Scribd company logo
OPERATORS
Problem Solving and Python Programming 2
‡ An operator is a symbol that represents an
operations that may be performed on one or
more operands.
‡ An operand is a value that a given operator is
applied to.
‡ Example: 4+(3*k)
+, * are operator and 4,3,k are operands
Different forms of operator
‡ Unary Operator:
± Unary arithmetic operators perform mathematical operations on
RQHRSHUDQGRQO7KHµ¶DQGµ-µ¶are two unary operators.
± Example:
 x = -5 #Negates the value of X
 x
-5
‡ Binary operator:
± A Binary operator operates on two operands
± Example:
 3 + 10
13
 10 ± 7
 3
Problem Solving and Python Programming 3
Types of Operators
1. Arithmetic operator
2. Relational operator
3. Logical operator
4. Bitwise operator
5. Assignment operator
6. Special operator
Problem Solving and Python Programming 4
1. Arithmetic operator
‡ Arithmetic operators are basic mathematical
operations.
Problem Solving and Python Programming 5
Operator Meaning Example Result
+ Addition C=12+1 C=13
- Subtraction C=12-1 C=11
* Multiplication C=12*1 C=12
/ Division C=12/1 C=12
// Floor division C=12//10 1
% Modulus C=12%10 C=2
** Exponentiation C=10**2 C=100
Example of Arithmetic Operator
print(Arithmetic Operator)
a=10
b=5
print(Addition:,a+b)
print(Subtraction:,a-b)
print(Multiplication:,a*b)
print(Division:,a/b)
print(Floor Division:,a//b)
print(Modulus:,a%b)
print(Exponent,a**b)
Problem Solving and Python Programming 6
Output:
2. Relational operator
‡ Relational operators are also called as Comparison
operators
‡ It is used to compare values.
‡ It either returns True or False according to condition.
Problem Solving and Python Programming 7
Operator Meaning Example Result
 Greater than 56 False
 Less than 56 True
== Equal to 5==6 False
!= Not equal to 5!=6 True
= Greater than or equal to 5=6 False
= Less than or equal to 5=6 True
Example of Relational Operator
print(Relational Operator)
a=10
b=5
print(ab)
print(ab)
print(a==b)
print(a!=b)
print(a=b)
print(a=b)
Problem Solving and Python Programming 8
Output:
3. Logical operator
Problem Solving and Python Programming 9
‡ Logical operator are typically used with
Boolean(logical) values.
‡ They allow a program to make a decision
based on multiple condition.
Operator Meaning Example Result
and True if both the
operands are true
105 and 1020 False
or True if either of the
operands is true
105 or 1020 True
not True if operands is
false ( complements
the operand)
not (1020) False
Example of Logical Operator
print(Logical Operator)
print(105 and 1020)
print(105 or 1020)
print(not(1020))
Problem Solving and Python Programming 10
Logical Operator
False
True
False
Output:
4. Bitwise operator
‡ Bitwise operators act on operands as if they are
string of binary digits.
‡ It operates bit by bit.
Problem Solving and Python Programming 11
Operator Meaning Example
 Bitwise AND a  b
| Bitwise OR a | b
~ Bitwise NOT a ~ b
^ Bitwise XOR a ^ b
 Bitwise right shift a  2
 Bitwise left shift a  2
5. Assignment operator
‡ Assignment operators are used to assign values
to variables.
Problem Solving and Python Programming 12
Operator Meaning Example
= Assign a value a=5
+= Adds and assign the result to the variable a+=1 (a=a+1)
-= Subtracts and assign the result to the variable a-=1 (a=a-1)
*= Multiplies and assign the result to the variable a*=5 (a=a*5)
/= Division and assign the result to the variable a/= (a=a/5)
//= Floor division and assign the result to the variable a//=5(a=a//5)
%= Find modulus and assign the result to the variable a%=5 (a=a%5)
**= Find Exponentiation and assign the result to the
variable
a**=5 (a=a**5)
Problem Solving and Python Programming 13
Operator Meaning Example
= Find Bitwise AND and assign the result to the variable a=5(a=a5)
|= Find Bitwise OR and assign the result to the variable a|=5(a=a|5)
^= Find Bitwise XOR and assign the result to the variable a^=5(a=a^5)
= Find Bitwise right shift and assign the result to the
variable
a=5 (a=a5)
= Find Bitwise left shift and assign the result to the
variable
a=5 (a=a5)
6. Special operator
‡ Python offers some special operators like
identity operator and the membership operator.
‡ Identity Operator:
± is and is not are the identity operator
Problem Solving and Python Programming 14
Operator Meaning Example
is True if the operands
are identical
a is true
is not True if the operands
are not identical
a is not true
Example of Identity Operator
a1=5
b1=5
a2=Hello
b2=Hello
a3=[1,2,3]
b3=[1,2,3]
print(a1 is not b1)
print(a2 is b2)
print(a2 is b3)
Problem Solving and Python Programming 15
Output:
False
True
False
‡ Membership Operators:
± in and not in are the membership operators.
Problem Solving and Python Programming 16
Operator Meaning Example
in True if value/
variable is found in
the sequence
5 in a
not in True if value/
variable is not
found in the
sequence
5 not in a
Example of Membership Operator
a=Hello world
b={1,a,b,2}
print(H in a)
print(hello in a )
print(1 in b)
print(b in b)
3ULQW ³F´QRWLQE
Problem Solving and Python Programming 17
Output:
True
False
True
True
True

More Related Content

Similar to Operators_in_Python_Simplified_languages

Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
bajiajugal
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
CtOlaf
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
Gunjan Mathur
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
Abdul Samee
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
Abdul Samee
 
Lecture 05.pptx
Lecture 05.pptxLecture 05.pptx
Lecture 05.pptx
Mohammad Hassan
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
Praveen M Jigajinni
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressions
maznabili
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
savitamhaske
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
Intro C# Book
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
Stoian Kirov
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
Chukka Nikhil Chakravarthy
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
sunny khan
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
Mohd Harris Ahmad Jaal
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
classall
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
VAIBHAV175947
 
05 operators
05   operators05   operators
05 operators
dhrubo kayal
 
Coper in C
Coper in CCoper in C
Coper in C
thirumalaikumar3
 

Similar to Operators_in_Python_Simplified_languages (20)

Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
 
Lecture 05.pptx
Lecture 05.pptxLecture 05.pptx
Lecture 05.pptx
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressions
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
05 operators
05   operators05   operators
05 operators
 
Coper in C
Coper in CCoper in C
Coper in C
 

Recently uploaded

Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
gaafergoudaay7aga
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 

Recently uploaded (20)

Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 

Operators_in_Python_Simplified_languages

  • 1. OPERATORS Problem Solving and Python Programming 2 ‡ An operator is a symbol that represents an operations that may be performed on one or more operands. ‡ An operand is a value that a given operator is applied to. ‡ Example: 4+(3*k) +, * are operator and 4,3,k are operands
  • 2. Different forms of operator ‡ Unary Operator: ± Unary arithmetic operators perform mathematical operations on RQHRSHUDQGRQO7KHµ¶DQGµ-µ¶are two unary operators. ± Example: x = -5 #Negates the value of X x -5 ‡ Binary operator: ± A Binary operator operates on two operands ± Example: 3 + 10 13 10 ± 7 3 Problem Solving and Python Programming 3
  • 3. Types of Operators 1. Arithmetic operator 2. Relational operator 3. Logical operator 4. Bitwise operator 5. Assignment operator 6. Special operator Problem Solving and Python Programming 4
  • 4. 1. Arithmetic operator ‡ Arithmetic operators are basic mathematical operations. Problem Solving and Python Programming 5 Operator Meaning Example Result + Addition C=12+1 C=13 - Subtraction C=12-1 C=11 * Multiplication C=12*1 C=12 / Division C=12/1 C=12 // Floor division C=12//10 1 % Modulus C=12%10 C=2 ** Exponentiation C=10**2 C=100
  • 5. Example of Arithmetic Operator print(Arithmetic Operator) a=10 b=5 print(Addition:,a+b) print(Subtraction:,a-b) print(Multiplication:,a*b) print(Division:,a/b) print(Floor Division:,a//b) print(Modulus:,a%b) print(Exponent,a**b) Problem Solving and Python Programming 6 Output:
  • 6. 2. Relational operator ‡ Relational operators are also called as Comparison operators ‡ It is used to compare values. ‡ It either returns True or False according to condition. Problem Solving and Python Programming 7 Operator Meaning Example Result Greater than 56 False Less than 56 True == Equal to 5==6 False != Not equal to 5!=6 True = Greater than or equal to 5=6 False = Less than or equal to 5=6 True
  • 7. Example of Relational Operator print(Relational Operator) a=10 b=5 print(ab) print(ab) print(a==b) print(a!=b) print(a=b) print(a=b) Problem Solving and Python Programming 8 Output:
  • 8. 3. Logical operator Problem Solving and Python Programming 9 ‡ Logical operator are typically used with Boolean(logical) values. ‡ They allow a program to make a decision based on multiple condition. Operator Meaning Example Result and True if both the operands are true 105 and 1020 False or True if either of the operands is true 105 or 1020 True not True if operands is false ( complements the operand) not (1020) False
  • 9. Example of Logical Operator print(Logical Operator) print(105 and 1020) print(105 or 1020) print(not(1020)) Problem Solving and Python Programming 10 Logical Operator False True False Output:
  • 10. 4. Bitwise operator ‡ Bitwise operators act on operands as if they are string of binary digits. ‡ It operates bit by bit. Problem Solving and Python Programming 11 Operator Meaning Example Bitwise AND a b | Bitwise OR a | b ~ Bitwise NOT a ~ b ^ Bitwise XOR a ^ b Bitwise right shift a 2 Bitwise left shift a 2
  • 11. 5. Assignment operator ‡ Assignment operators are used to assign values to variables. Problem Solving and Python Programming 12 Operator Meaning Example = Assign a value a=5 += Adds and assign the result to the variable a+=1 (a=a+1) -= Subtracts and assign the result to the variable a-=1 (a=a-1) *= Multiplies and assign the result to the variable a*=5 (a=a*5) /= Division and assign the result to the variable a/= (a=a/5) //= Floor division and assign the result to the variable a//=5(a=a//5) %= Find modulus and assign the result to the variable a%=5 (a=a%5) **= Find Exponentiation and assign the result to the variable a**=5 (a=a**5)
  • 12. Problem Solving and Python Programming 13 Operator Meaning Example = Find Bitwise AND and assign the result to the variable a=5(a=a5) |= Find Bitwise OR and assign the result to the variable a|=5(a=a|5) ^= Find Bitwise XOR and assign the result to the variable a^=5(a=a^5) = Find Bitwise right shift and assign the result to the variable a=5 (a=a5) = Find Bitwise left shift and assign the result to the variable a=5 (a=a5)
  • 13. 6. Special operator ‡ Python offers some special operators like identity operator and the membership operator. ‡ Identity Operator: ± is and is not are the identity operator Problem Solving and Python Programming 14 Operator Meaning Example is True if the operands are identical a is true is not True if the operands are not identical a is not true
  • 14. Example of Identity Operator a1=5 b1=5 a2=Hello b2=Hello a3=[1,2,3] b3=[1,2,3] print(a1 is not b1) print(a2 is b2) print(a2 is b3) Problem Solving and Python Programming 15 Output: False True False
  • 15. ‡ Membership Operators: ± in and not in are the membership operators. Problem Solving and Python Programming 16 Operator Meaning Example in True if value/ variable is found in the sequence 5 in a not in True if value/ variable is not found in the sequence 5 not in a
  • 16. Example of Membership Operator a=Hello world b={1,a,b,2} print(H in a) print(hello in a ) print(1 in b) print(b in b) 3ULQW ³F´QRWLQE Problem Solving and Python Programming 17 Output: True False True True True