SlideShare a Scribd company logo
1 of 18
OPERATORS IN PYTHON
OPERATORS IN PYTHON
10/11/2021 OPEARATORS IN PYTHON 2
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operator
Assignment Operator
Special Operator
ARITHMETIC
OPERATORS IN
PYTHON
Arithmetic
operators are used
to perform
mathematical
operations like
addition,
subtraction,
multiplication, etc.
10/11/2021 OPEARATORS IN PYTHON 3
Operator Description Syntax
+ Add two operands or unary plus x+y+2
- Subtract right operand from the
left or unary minus
x-y-2
* Multiply two operands x*y
** Exponent - left operand raised to
the power of right
x**y
/ Divide left operand by the right
one (always results into float)
x/y
// Floor division - division that
results into whole number
adjusted to the left in the number
line
x//y
% Modulus - remainder of the
division of left operand by the
right
x%y
ARITHMETIC
OPERATORS IN
PYTHON
Practical approach :
Arithmetic
operators
execution with
output
10/11/2021 OPEARATORS IN PYTHON 4
COMPARISION
OPERATORS IN
PYTHON
Comparison
operators are used
to compare values.
It returns either
True or False
according to the
condition.
10/11/2021 OPEARATORS IN PYTHON 5
Operator Description Syntax
> Greater than - True if left operand
is greater than the right
x>y
< Less than - True if left operand is
less than the right
y<x
== Equal to - True if both operands
are equal
x==y
!= Not equal to - True if operands
are not equal
x!=y
>= Greater than or equal to - True if
left operand is greater than or
equal to the right
x>=y
<= Less than or equal to - True if left
operand is less than or equal to
the right
x<=y
COMPARISION
OPERATORS IN
PYTHON
Practical approach :
Comparision
operators
execution with
output
10/11/2021 OPEARATORS IN PYTHON 6
BITWISE
OPERATORS IN
PYTHON
Bitwise operators
act on operands as
if they were strings
of binary digits.
They operate bit by
bit, hence the.
10/11/2021 OPEARATORS IN PYTHON 7
Operator Description Syntax
& Bitwise and x & y
| Bitwise or x|y
~ Bitwise not ~x
^ Bitwise XOR x ^ y
>> Bitwise right
shift
x>>y
<< Bitwise left shift x<<y
Truth Table
AND
OR
Ex-OR
A B A &B
0 0 0
0 1 0
1 0 0
1 1 1
A B A |B
0 0 0
0 1 1
1 0 1
1 1 1
A B A |B
0 0 0
0 1 1
1 0 1
1 1 0
Left shift
operator
e.g.x>>y
i.e.x*2^y
Right shift
operator
e.g.x>>y
i.e.x/2^y
Not
operator
Bitwise (Not) one's compliment operator will
invert the binary bits.
If a bit is 1, it will change it to 0.
If the bit is 0, it will change it to 1.
The ones' complement binary numeral system
is characterized by the bit complement of any
integer value being the arithmetic negative of
the value.
BITWISE
OPERATORS IN
PYTHON
Practical approach :
Bitwise operators
execution with
output
10/11/2021 OPEARATORS IN PYTHON 12
LOGICAL
OPERATORS IN
PYTHON
Logical operators
are and,or & not
operators. It returns
either True or False
according to the
operator.
Practical approach :
Comparision
operators
execution with
output
10/11/2021 OPEARATORS IN PYTHON 13
Operator Description Syntax
and True if both the operands are true x and y
or True if either of the operands is
true
x or y
not True if operand is false
(complements the operand)
x not y
ASSIGNMENT
OPERATORS IN
PYTHON
Assignment operators
are used to assign
values to variables.
There are various
compound operators
in Python like a+=5
that adds to the
variable and later
assigns the same. It is
equivalent to a=a+5
10/11/2021 OPEARATORS IN PYTHON 14
Operator Example Equivalent to
= x=7 x=7
+= x+=7 x=x+7
-= x-=7 x=x-7
*= x*=7 x=x*7
/= x/=7 x=x/7
//= x//=7 x=x//7
%= x%=7 x=x%7
**= x**=7 x=x**7
&= x&=7 x=x&7
|= x|=7 x=x|7
^= x^=7 x=x^7
>>= x>>=7 x=x>>7
<<= x<<=7 x<<7
Special Operators
Identity operator
is and is not are the identity
operators in Python. They are used
to check if two values (or
variables) are located on the same
part of the memory.
Membership
Operator
in and not in are the membership
operators in Python. They are used
to test whether a value or variable
is found in a sequence
(string,list,tuple,set and
dictionary)
Difference between is and == operator
The is keyword is used to test if
two variables refer to the same
object.
The test returns True if the two
objects are the same object.
The test returns False if they
are not the same object, even if
the two objects are 100%
equal.
Use the == operator to test if
two variables are equal.
SPECIAL
OPERATORS IN
PYTHON
Practical approach :
special operators
execution with
output
10/11/2021 OPEARATORS IN PYTHON 17
Python
Operator
Precedence
Precedence Operator Sign Operator Name
Highest () Parentheses
** Exponent
+x,-x,~x Unary plus, Unary
minus, Bitwise
NOT
*,/,//,% Multiplication,
Division, Floor
division, Modulus
+,- Addition,
Subtraction
<<,>> Bitwise shift
operator
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
Lowest ==,!=,>,>=,<,<=,is,is
not,in,not in
Comparision,Ident
ity ,Membership
operators

More Related Content

What's hot (20)

Python ppt
Python pptPython ppt
Python ppt
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentation
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Operators and Control Statements in Python
Operators and Control Statements in PythonOperators and Control Statements in Python
Operators and Control Statements in Python
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
 
Conditionalstatement
ConditionalstatementConditionalstatement
Conditionalstatement
 
C pointers
C pointersC pointers
C pointers
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
Sorting in python
Sorting in python Sorting in python
Sorting in python
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Python : Operators
Python : OperatorsPython : Operators
Python : Operators
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
 

Similar to Operators in python

Python Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.inPython Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.inLearnbayin
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statementsCtOlaf
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions NotesProf Ansari
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.netJaya Kumari
 
python operators.ppt
python operators.pptpython operators.ppt
python operators.pptErnieAcuna
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingRahul Tandale
 
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 5FabMinds
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptxclassall
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
Operators
OperatorsOperators
OperatorsKamran
 

Similar to Operators in python (20)

Python Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.inPython Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.in
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
 
Operators
OperatorsOperators
Operators
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Java script operators
Java script operatorsJava script operators
Java script operators
 
python operators.ppt
python operators.pptpython operators.ppt
python operators.ppt
 
5_Operators.pdf
5_Operators.pdf5_Operators.pdf
5_Operators.pdf
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online Training
 
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
 
Java - Operators
Java - OperatorsJava - Operators
Java - Operators
 
Java 2
Java 2Java 2
Java 2
 
Coper in C
Coper in CCoper in C
Coper in C
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Operators and it's type
Operators and it's type Operators and it's type
Operators and it's type
 
Operators
OperatorsOperators
Operators
 
Report on c
Report on cReport on c
Report on c
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Operators in java
Operators in javaOperators in java
Operators in java
 

More from deepalishinkar1

Practical approach on numbers system and math module
Practical approach on numbers system and math modulePractical approach on numbers system and math module
Practical approach on numbers system and math moduledeepalishinkar1
 
Demonstration on keyword
Demonstration on keywordDemonstration on keyword
Demonstration on keyworddeepalishinkar1
 
Basic concepts of python
Basic concepts of pythonBasic concepts of python
Basic concepts of pythondeepalishinkar1
 
Data type list_methods_in_python
Data type list_methods_in_pythonData type list_methods_in_python
Data type list_methods_in_pythondeepalishinkar1
 

More from deepalishinkar1 (8)

Data handling in python
Data handling in pythonData handling in python
Data handling in python
 
Practical approach on numbers system and math module
Practical approach on numbers system and math modulePractical approach on numbers system and math module
Practical approach on numbers system and math module
 
Demonstration on keyword
Demonstration on keywordDemonstration on keyword
Demonstration on keyword
 
Numbers and math module
Numbers and math moduleNumbers and math module
Numbers and math module
 
Basic concepts of python
Basic concepts of pythonBasic concepts of python
Basic concepts of python
 
Introduction to python
Introduction to python Introduction to python
Introduction to python
 
Set methods in python
Set methods in pythonSet methods in python
Set methods in python
 
Data type list_methods_in_python
Data type list_methods_in_pythonData type list_methods_in_python
Data type list_methods_in_python
 

Recently uploaded

Issues in the Philippines (Unemployment and Underemployment).pptx
Issues in the Philippines (Unemployment and Underemployment).pptxIssues in the Philippines (Unemployment and Underemployment).pptx
Issues in the Philippines (Unemployment and Underemployment).pptxJenniferPeraro1
 
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...Suhani Kapoor
 
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...Suhani Kapoor
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一Fs
 
Ch. 9- __Skin, hair and nail Assessment (1).pdf
Ch. 9- __Skin, hair and nail Assessment (1).pdfCh. 9- __Skin, hair and nail Assessment (1).pdf
Ch. 9- __Skin, hair and nail Assessment (1).pdfJamalYaseenJameelOde
 
Application deck- Cyril Caudroy-2024.pdf
Application deck- Cyril Caudroy-2024.pdfApplication deck- Cyril Caudroy-2024.pdf
Application deck- Cyril Caudroy-2024.pdfCyril CAUDROY
 
定制英国克兰菲尔德大学毕业证成绩单原版一比一
定制英国克兰菲尔德大学毕业证成绩单原版一比一定制英国克兰菲尔德大学毕业证成绩单原版一比一
定制英国克兰菲尔德大学毕业证成绩单原版一比一z zzz
 
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
Call Girl in Low Price Delhi Punjabi Bagh  9711199012Call Girl in Low Price Delhi Punjabi Bagh  9711199012
Call Girl in Low Price Delhi Punjabi Bagh 9711199012sapnasaifi408
 
办理老道明大学毕业证成绩单|购买美国ODU文凭证书
办理老道明大学毕业证成绩单|购买美国ODU文凭证书办理老道明大学毕业证成绩单|购买美国ODU文凭证书
办理老道明大学毕业证成绩单|购买美国ODU文凭证书saphesg8
 
原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证
原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证
原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证diploma001
 
定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一
定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一
定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一lvtagr7
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of JobRemote DBA Services
 
tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...vinbld123
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一Fs sss
 
Gray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdfGray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdfpadillaangelina0023
 
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一
如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一
如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一ypfy7p5ld
 
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
Kindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docxKindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docxLesterJayAquino
 

Recently uploaded (20)

Issues in the Philippines (Unemployment and Underemployment).pptx
Issues in the Philippines (Unemployment and Underemployment).pptxIssues in the Philippines (Unemployment and Underemployment).pptx
Issues in the Philippines (Unemployment and Underemployment).pptx
 
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
 
Young Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort Service
Young Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort ServiceYoung Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort Service
Young Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort Service
 
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
 
Ch. 9- __Skin, hair and nail Assessment (1).pdf
Ch. 9- __Skin, hair and nail Assessment (1).pdfCh. 9- __Skin, hair and nail Assessment (1).pdf
Ch. 9- __Skin, hair and nail Assessment (1).pdf
 
Application deck- Cyril Caudroy-2024.pdf
Application deck- Cyril Caudroy-2024.pdfApplication deck- Cyril Caudroy-2024.pdf
Application deck- Cyril Caudroy-2024.pdf
 
定制英国克兰菲尔德大学毕业证成绩单原版一比一
定制英国克兰菲尔德大学毕业证成绩单原版一比一定制英国克兰菲尔德大学毕业证成绩单原版一比一
定制英国克兰菲尔德大学毕业证成绩单原版一比一
 
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
Call Girl in Low Price Delhi Punjabi Bagh  9711199012Call Girl in Low Price Delhi Punjabi Bagh  9711199012
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
 
办理老道明大学毕业证成绩单|购买美国ODU文凭证书
办理老道明大学毕业证成绩单|购买美国ODU文凭证书办理老道明大学毕业证成绩单|购买美国ODU文凭证书
办理老道明大学毕业证成绩单|购买美国ODU文凭证书
 
原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证
原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证
原版定制卡尔加里大学毕业证(UC毕业证)留信学历认证
 
定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一
定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一
定制(UQ毕业证书)澳洲昆士兰大学毕业证成绩单原版一比一
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Job
 
tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 
Gray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdfGray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdf
 
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
 
如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一
如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一
如何办理(UCI毕业证)加州大学欧文分校毕业证毕业证成绩单原版一比一
 
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
 
Kindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docxKindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docx
 

Operators in python

  • 2. OPERATORS IN PYTHON 10/11/2021 OPEARATORS IN PYTHON 2 Arithmetic Operators Relational Operators Logical Operators Bitwise Operator Assignment Operator Special Operator
  • 3. ARITHMETIC OPERATORS IN PYTHON Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, etc. 10/11/2021 OPEARATORS IN PYTHON 3 Operator Description Syntax + Add two operands or unary plus x+y+2 - Subtract right operand from the left or unary minus x-y-2 * Multiply two operands x*y ** Exponent - left operand raised to the power of right x**y / Divide left operand by the right one (always results into float) x/y // Floor division - division that results into whole number adjusted to the left in the number line x//y % Modulus - remainder of the division of left operand by the right x%y
  • 4. ARITHMETIC OPERATORS IN PYTHON Practical approach : Arithmetic operators execution with output 10/11/2021 OPEARATORS IN PYTHON 4
  • 5. COMPARISION OPERATORS IN PYTHON Comparison operators are used to compare values. It returns either True or False according to the condition. 10/11/2021 OPEARATORS IN PYTHON 5 Operator Description Syntax > Greater than - True if left operand is greater than the right x>y < Less than - True if left operand is less than the right y<x == Equal to - True if both operands are equal x==y != Not equal to - True if operands are not equal x!=y >= Greater than or equal to - True if left operand is greater than or equal to the right x>=y <= Less than or equal to - True if left operand is less than or equal to the right x<=y
  • 6. COMPARISION OPERATORS IN PYTHON Practical approach : Comparision operators execution with output 10/11/2021 OPEARATORS IN PYTHON 6
  • 7. BITWISE OPERATORS IN PYTHON Bitwise operators act on operands as if they were strings of binary digits. They operate bit by bit, hence the. 10/11/2021 OPEARATORS IN PYTHON 7 Operator Description Syntax & Bitwise and x & y | Bitwise or x|y ~ Bitwise not ~x ^ Bitwise XOR x ^ y >> Bitwise right shift x>>y << Bitwise left shift x<<y
  • 8. Truth Table AND OR Ex-OR A B A &B 0 0 0 0 1 0 1 0 0 1 1 1 A B A |B 0 0 0 0 1 1 1 0 1 1 1 1 A B A |B 0 0 0 0 1 1 1 0 1 1 1 0
  • 11. Not operator Bitwise (Not) one's compliment operator will invert the binary bits. If a bit is 1, it will change it to 0. If the bit is 0, it will change it to 1. The ones' complement binary numeral system is characterized by the bit complement of any integer value being the arithmetic negative of the value.
  • 12. BITWISE OPERATORS IN PYTHON Practical approach : Bitwise operators execution with output 10/11/2021 OPEARATORS IN PYTHON 12
  • 13. LOGICAL OPERATORS IN PYTHON Logical operators are and,or & not operators. It returns either True or False according to the operator. Practical approach : Comparision operators execution with output 10/11/2021 OPEARATORS IN PYTHON 13 Operator Description Syntax and True if both the operands are true x and y or True if either of the operands is true x or y not True if operand is false (complements the operand) x not y
  • 14. ASSIGNMENT OPERATORS IN PYTHON Assignment operators are used to assign values to variables. There are various compound operators in Python like a+=5 that adds to the variable and later assigns the same. It is equivalent to a=a+5 10/11/2021 OPEARATORS IN PYTHON 14 Operator Example Equivalent to = x=7 x=7 += x+=7 x=x+7 -= x-=7 x=x-7 *= x*=7 x=x*7 /= x/=7 x=x/7 //= x//=7 x=x//7 %= x%=7 x=x%7 **= x**=7 x=x**7 &= x&=7 x=x&7 |= x|=7 x=x|7 ^= x^=7 x=x^7 >>= x>>=7 x=x>>7 <<= x<<=7 x<<7
  • 15. Special Operators Identity operator is and is not are the identity operators in Python. They are used to check if two values (or variables) are located on the same part of the memory. Membership Operator in and not in are the membership operators in Python. They are used to test whether a value or variable is found in a sequence (string,list,tuple,set and dictionary)
  • 16. Difference between is and == operator The is keyword is used to test if two variables refer to the same object. The test returns True if the two objects are the same object. The test returns False if they are not the same object, even if the two objects are 100% equal. Use the == operator to test if two variables are equal.
  • 17. SPECIAL OPERATORS IN PYTHON Practical approach : special operators execution with output 10/11/2021 OPEARATORS IN PYTHON 17
  • 18. Python Operator Precedence Precedence Operator Sign Operator Name Highest () Parentheses ** Exponent +x,-x,~x Unary plus, Unary minus, Bitwise NOT *,/,//,% Multiplication, Division, Floor division, Modulus +,- Addition, Subtraction <<,>> Bitwise shift operator & Bitwise AND ^ Bitwise XOR | Bitwise OR Lowest ==,!=,>,>=,<,<=,is,is not,in,not in Comparision,Ident ity ,Membership operators