SlideShare a Scribd company logo
11
Most read
Python
a programming language
Class 2
Python Operators
 Operators are used to perform operations on variables and values
 Python divides the operators in the following groups
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Identity operators
 Membership operators
 Bitwise operators
Python Arithmetic operators
Operator Name Example
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
% Modulus x % y
** Exponentiation x ** y
// Floor division x // y
Python Assignment Operators
Operator Example Same As
= x = 5 x = 5
+= x += 3 x = x + 3
-= x -= 3 x = x - 3
*= x *= 3 x = x * 3
/= x /= 3 x = x / 3
%= x %= 3 x = x % 3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
&= x &= 3 x = x & 3
|= x |= 3 x = x | 3
^= x ^= 3 x = x ^ 3
>>= x >>= 3 x = x >> 3
<<= x <<= 3 x = x << 3
Python Comparison Operators
Operator Name Example
== Equal x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y
Python Logical Operators
Operator Description Example
and Returns True if both statements
are true
x < 5 and x < 10
or Returns True if one of the
statements is true
x < 5 or x < 4
not Reverse the result, returns False
if the result is true
not(x < 5 and x < 10)
Python Identity Operators
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
Python Membership Operators
Operator Description Example
in Returns True if a sequence
with the specified value is
present in the object
x in y
not in Returns True if a sequence
with the specified value is
not present in the object
x not in y
Python Bitwise Operators
Operat
or
Name Description
& AND Sets each bit to 1 if both bits are 1
| OR Sets each bit to 1 if one of two bits is 1
^ XOR Sets each bit to 1 if only one of two bits is 1
~ NOT Inverts all the bits
<< Zero fill
left shift
Shift left by pushing zeros in from the right and let
the leftmost bits fall off
>> Signed
right
shift
Shift right by pushing copies of the leftmost bit in
from the left, and let the rightmost bits fall off
Exercise
 Multiply 10 with 5 and print the result.
 Divide 10 by 2, and print the result
 If 5____ 10:
 Print (“5 and 10 is not equal”)
Program time
 1.Print Hello World
 2. Add Two numbers
 3.Take an input from user and display the same.
 4. Find the square of a number.

More Related Content

PPTX
Operators in python
deepalishinkar1
 
PDF
Operators in python
eShikshak
 
PPTX
Python Flow Control
Kamal Acharya
 
PPTX
Operators in Python
Anusuya123
 
PDF
Introduction to Python
Mohammed Sikander
 
PPTX
Python Datatypes by SujithKumar
Sujith Kumar
 
PDF
Python functions
Prof. Dr. K. Adisesha
 
Operators in python
deepalishinkar1
 
Operators in python
eShikshak
 
Python Flow Control
Kamal Acharya
 
Operators in Python
Anusuya123
 
Introduction to Python
Mohammed Sikander
 
Python Datatypes by SujithKumar
Sujith Kumar
 
Python functions
Prof. Dr. K. Adisesha
 

What's hot (20)

PDF
Python programming : Arrays
Emertxe Information Technologies Pvt Ltd
 
PPTX
Strings in c++
Neeru Mittal
 
PPTX
Operators and expressions in c language
tanmaymodi4
 
PDF
Operators in c programming
savitamhaske
 
PPTX
Infix to postfix conversion
Then Murugeshwari
 
PDF
Operators in python
Prabhakaran V M
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PDF
Computer graphics lab report with code in cpp
Alamgir Hossain
 
PPTX
Functions in python slide share
Devashish Kumar
 
PDF
C Pointers
omukhtar
 
PPTX
Pointers in c++
Vineeta Garg
 
PPTX
Queue in Data Structure
Janki Shah
 
PDF
Python recursion
Prof. Dr. K. Adisesha
 
PPTX
Python basics
RANAALIMAJEEDRAJPUT
 
PPTX
String Manipulation in Python
Pooja B S
 
PPTX
Looping statement in python
RaginiJain21
 
PDF
List,tuple,dictionary
nitamhaske
 
PPTX
Recursion
Abdur Rehman
 
PDF
Introduction to python
Mohammed Rafi
 
Python programming : Arrays
Emertxe Information Technologies Pvt Ltd
 
Strings in c++
Neeru Mittal
 
Operators and expressions in c language
tanmaymodi4
 
Operators in c programming
savitamhaske
 
Infix to postfix conversion
Then Murugeshwari
 
Operators in python
Prabhakaran V M
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Functions in python slide share
Devashish Kumar
 
C Pointers
omukhtar
 
Pointers in c++
Vineeta Garg
 
Queue in Data Structure
Janki Shah
 
Python recursion
Prof. Dr. K. Adisesha
 
Python basics
RANAALIMAJEEDRAJPUT
 
String Manipulation in Python
Pooja B S
 
Looping statement in python
RaginiJain21
 
List,tuple,dictionary
nitamhaske
 
Recursion
Abdur Rehman
 
Introduction to python
Mohammed Rafi
 
Ad

Similar to Python Operators (20)

PPTX
Understanding All Types of Operators in Python with Examples"
mansurimohammadfaiza
 
PPTX
python operators.pptx
irsatanoli
 
PPTX
Python Lec-6 Operatorguijjjjuugggggs.pptx
ks812227
 
PPTX
Operators in Python Arithmetic Operators
ramireddyobulakondar
 
PPTX
Python operators
nuripatidar
 
PPTX
Python programming language introduction unit
michaelaaron25322
 
PDF
Operators_in_Python_Simplified_languages
AbhishekGupta692777
 
PPTX
PYTHON OPERATORS 123Python Operators.pptx
AnjaneyuluKunchala1
 
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
PDF
Python : basic operators
S.M. Salaquzzaman
 
PPTX
Operators Concept in Python-N.Kavitha.pptx
Kavitha713564
 
PPTX
operatorsinpython-18112209560412 (1).pptx
urvashipundir04
 
PPTX
python statement, expressions and operators.pptx
richumt
 
PPTX
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
PDF
Python Basic Operators
Soba Arjun
 
PPTX
Python operators
SaurabhUpadhyay73
 
PPTX
3. Operators in python programming..pptx
tigercodingschool
 
PPTX
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
PPTX
OPERATOR IN PYTHON-PART2
vikram mahendra
 
PPTX
Python assignment 1 Biswajit Mohapatra.pptx
BiswajitMohapatra59
 
Understanding All Types of Operators in Python with Examples"
mansurimohammadfaiza
 
python operators.pptx
irsatanoli
 
Python Lec-6 Operatorguijjjjuugggggs.pptx
ks812227
 
Operators in Python Arithmetic Operators
ramireddyobulakondar
 
Python operators
nuripatidar
 
Python programming language introduction unit
michaelaaron25322
 
Operators_in_Python_Simplified_languages
AbhishekGupta692777
 
PYTHON OPERATORS 123Python Operators.pptx
AnjaneyuluKunchala1
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
Python : basic operators
S.M. Salaquzzaman
 
Operators Concept in Python-N.Kavitha.pptx
Kavitha713564
 
operatorsinpython-18112209560412 (1).pptx
urvashipundir04
 
python statement, expressions and operators.pptx
richumt
 
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
Python Basic Operators
Soba Arjun
 
Python operators
SaurabhUpadhyay73
 
3. Operators in python programming..pptx
tigercodingschool
 
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
OPERATOR IN PYTHON-PART2
vikram mahendra
 
Python assignment 1 Biswajit Mohapatra.pptx
BiswajitMohapatra59
 
Ad

Recently uploaded (20)

PPTX
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
PPTX
Edge to Cloud Protocol HTTP WEBSOCKET MQTT-SN MQTT.pptx
dhanashri894551
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
PPTX
Ship’s Structural Components.pptx 7.7 Mb
abdalwhab7327
 
PPT
High Data Link Control Protocol in Data Link Layer
shailajacse
 
PPTX
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
shravanidabhane8
 
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
VinayB68
 
PPTX
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
PDF
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
VICTOR MAESTRE RAMIREZ
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
quakeplayz54
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
Edge to Cloud Protocol HTTP WEBSOCKET MQTT-SN MQTT.pptx
dhanashri894551
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
Ppt for engineering students application on field effect
lakshmi.ec
 
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
Ship’s Structural Components.pptx 7.7 Mb
abdalwhab7327
 
High Data Link Control Protocol in Data Link Layer
shailajacse
 
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
shravanidabhane8
 
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
VinayB68
 
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
VICTOR MAESTRE RAMIREZ
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Lesson 3_Tessellation.pptx finite Mathematics
quakeplayz54
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 

Python Operators

  • 2. Python Operators  Operators are used to perform operations on variables and values  Python divides the operators in the following groups  Arithmetic operators  Assignment operators  Comparison operators  Logical operators  Identity operators  Membership operators  Bitwise operators
  • 3. Python Arithmetic operators Operator Name Example + Addition x + y - Subtraction x - y * Multiplication x * y / Division x / y % Modulus x % y ** Exponentiation x ** y // Floor division x // y
  • 4. Python Assignment Operators Operator Example Same As = x = 5 x = 5 += x += 3 x = x + 3 -= x -= 3 x = x - 3 *= x *= 3 x = x * 3 /= x /= 3 x = x / 3 %= x %= 3 x = x % 3 //= x //= 3 x = x // 3 **= x **= 3 x = x ** 3 &= x &= 3 x = x & 3 |= x |= 3 x = x | 3 ^= x ^= 3 x = x ^ 3 >>= x >>= 3 x = x >> 3 <<= x <<= 3 x = x << 3
  • 5. Python Comparison Operators Operator Name Example == Equal x == y != Not equal x != y > Greater than x > y < Less than x < y >= Greater than or equal to x >= y <= Less than or equal to x <= y
  • 6. Python Logical Operators Operator Description Example and Returns True if both statements are true x < 5 and x < 10 or Returns True if one of the statements is true x < 5 or x < 4 not Reverse the result, returns False if the result is true not(x < 5 and x < 10)
  • 7. Python Identity Operators 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
  • 8. Python Membership Operators Operator Description Example in Returns True if a sequence with the specified value is present in the object x in y not in Returns True if a sequence with the specified value is not present in the object x not in y
  • 9. Python Bitwise Operators Operat or Name Description & AND Sets each bit to 1 if both bits are 1 | OR Sets each bit to 1 if one of two bits is 1 ^ XOR Sets each bit to 1 if only one of two bits is 1 ~ NOT Inverts all the bits << Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall off >> Signed right shift Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
  • 10. Exercise  Multiply 10 with 5 and print the result.  Divide 10 by 2, and print the result  If 5____ 10:  Print (“5 and 10 is not equal”)
  • 11. Program time  1.Print Hello World  2. Add Two numbers  3.Take an input from user and display the same.  4. Find the square of a number.