SlideShare a Scribd company logo
Operators
Team Emertxe
Arithmetic
OPERATORS
Arithmetic
Operator Example Result
+ a + b 18
- a - b 8
* a * b 65
/ a / b 2.6
% a % b 3
** a ** b 371293
// a // b 2
The results are obtained for the values of:
a = 13
b = 5
OPERATORS
Assignment
Operators
=
+=
-+
*+
/=
%=
**=
//=
Example-1:
Example-2:
Example-3:
a = b = 1
a = 1; b = 1
a, b = 1, 2
Python does not have ++ AND -- operators
OPERATORS
Unary Minus
Example-1:
n = 10
print(-n)
Example-2:
num = -10
num = -num
print(num)
OPERATORS
Relational
Operator Example Result
> a > b False
>= a >= b False
< a < b True
<= a <= b True
== a == b False
!= a != b True
The results are obtained for the values of:
a = 1
b = 2
OPERATORS
Relational: Chaining
Example-1:
x = 15
print(10< x < 20)
Example-2:
print(1 < 2 < 3 < 4)
OPERATORS
Logical
Operator Example Result
and a and b 2
or a or b 1
not not a False
Short Circuit evaluation implies to Logical Operators
If a = 100, b = 200
Example-1:
if (a < b and b < c):
print("Yes")
else:
print("No")
Example-2:
if (a > b or b < c):
print("Yes")
else:
print("No")
OPERATORS
Boolean
Operator Example Result
and a and b False
or a or b True
not not a False
If a = True, b = False
Example-1:
print(a and b)
print(a or b)
print(not a)
OPERATORS
Bitwise
Operator Example Result
~ ~a 1111 0101(-11)
& a & b 0000 1010(10)
| a | b 0000 1011(11)
^ a ^ b 0000 0001(1)
<< a << 2 0010 1000(40)
>> a >> 2 0000 0010(2)
If a = 10(0000 1010), b = 11(0000 1011)
In case of >> shifting, it preserves the sign of the number.
OPERATORS
Membership
Operator Description
in Returns True, if an item is found in the specified sequence
not in Returns True, if an item is not found in the specified sequence
Example-1:
names = ["Ram", "Hari", "Thomas"]
for i in names:
print(i)
Example-2:
postal = {"Delhi": 110001, "Chennai": 600001, "Bangalore": 560001}
for city in postal:
print(city, postal[city])
OPERATORS
Identity
Operator Description
is Returns True, if ID of two objects are same
is not Returns True, if ID of two objects are not same

Use to comapre the memory locations of two objects

id(): Is used to get the memory location ID
Example-1:
a = 25
b = 25
if (a is b): #This compares only the locations
print("a and b are same")
OPERATORS
Identity

To compare two objects, use ‘==’ operator
Example-1:
a = [1, 2, 3, 4]
b = [1, 2, 3, 4]
if (a == b):
print("Objects are same")
else:
print("Objects are not same")
OPERATORS
Precedence & Associativity
Operator Name
(expressions...), [expressions...], {key:
value...}, {expressions...}
Binding or tuple display, list display, dictionary
display, set display
x[index], x[index:index], x(arguments...),
x.attribute
Subscription, slicing, call, attribute reference
** Exponentiation
+, -, ~ Positive, negative, bitwise NOT
*, @, /, //, % Multiplication, matrix multiplication, division,
floor division, remainder
+, - Addition, Subraction
<<, >> Bitwise Left, Right shift
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
in, not in, is, is not, <, <=, >, >=, !=, == Comparisons, including membership tests and identity
tests
not Boolean not
and Boolean and
or Boolean or
if-else Conditional Expression
lambda Lambda Expression
All operators follow, Left – Right associativity, except ** which
follows Right - Left
Mathematical Functions
Example-1:
import math
x = math.sqrt(16)
Example-2:
import math as m
x = m.sqrt(16)
Example-3:
from math import sqrt
x = sqrt(16)
Example-4:
from math import sqrt, factorial
x = sqrt(16)
y = factorial(5)
THANK YOU

More Related Content

What's hot

Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
MansiSuthar3
 
Python : Functions
Python : FunctionsPython : Functions
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
Mohd Sajjad
 
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)
Pedro Rodrigues
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Python : Data Types
Python : Data TypesPython : Data Types
Boolean and conditional logic in Python
Boolean and conditional logic in PythonBoolean and conditional logic in Python
Boolean and conditional logic in Python
gsdhindsa
 
Python functions
Python functionsPython functions
Python functions
Prof. Dr. K. Adisesha
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
Emertxe Information Technologies Pvt Ltd
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Kamal Acharya
 
Python GUI
Python GUIPython GUI
Python GUI
LusciousLarryDas
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
Paige Bailey
 
Lists
ListsLists
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
KrishnaMildain
 
Python Basics
Python BasicsPython Basics
Python Basics
tusharpanda88
 

What's hot (20)

Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
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)
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Boolean and conditional logic in Python
Boolean and conditional logic in PythonBoolean and conditional logic in Python
Boolean and conditional logic in Python
 
Python functions
Python functionsPython functions
Python functions
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Python GUI
Python GUIPython GUI
Python GUI
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Python basic
Python basicPython basic
Python basic
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Lists
ListsLists
Lists
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Python Basics
Python BasicsPython Basics
Python Basics
 

Similar to Python : Operators

C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
AmAn Singh
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
AmAn Singh
 
Operators
OperatorsOperators
Operators
Kamran
 
Operators in C
Operators in COperators in C
Operators in C
Prabhu Govind
 
This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
ranaashutosh531pvt
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)jahanullah
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
Darshan Patel
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3sotlsoc
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
Fiaz Khokhar
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
ruchisuru20001
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
Praveen M Jigajinni
 
Operators
OperatorsOperators
Operators
VijayaLakshmi506
 
Theory3
Theory3Theory3
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
Shobi P P
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionalish sha
 
C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 

Similar to Python : Operators (20)

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
 
Operators
OperatorsOperators
Operators
 
Operators in C
Operators in COperators in C
Operators in C
 
This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Operators
OperatorsOperators
Operators
 
Theory3
Theory3Theory3
Theory3
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
 
C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 

More from Emertxe Information Technologies Pvt Ltd

Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
Emertxe Information Technologies Pvt Ltd
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf

More from Emertxe Information Technologies Pvt Ltd (20)

premium post (1).pdf
premium post (1).pdfpremium post (1).pdf
premium post (1).pdf
 
Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
10_isxdigit.pdf
 
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
01_student_record.pdf
 
02_swap.pdf
02_swap.pdf02_swap.pdf
02_swap.pdf
 
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
01_sizeof.pdf
 
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
07_product_matrix.pdf
 
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
06_sort_names.pdf
 
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
05_fragments.pdf
 
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
04_magic_square.pdf
 
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
03_endianess.pdf
 
02_variance.pdf
02_variance.pdf02_variance.pdf
02_variance.pdf
 
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
01_memory_manager.pdf
 
09_nrps.pdf
09_nrps.pdf09_nrps.pdf
09_nrps.pdf
 
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
11_pangram.pdf
 
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
10_combinations.pdf
 
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
08_squeeze.pdf
 
07_strtok.pdf
07_strtok.pdf07_strtok.pdf
07_strtok.pdf
 
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
06_reverserec.pdf
 
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
05_reverseiter.pdf
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

Python : Operators

  • 3. OPERATORS Arithmetic Operator Example Result + a + b 18 - a - b 8 * a * b 65 / a / b 2.6 % a % b 3 ** a ** b 371293 // a // b 2 The results are obtained for the values of: a = 13 b = 5
  • 4. OPERATORS Assignment Operators = += -+ *+ /= %= **= //= Example-1: Example-2: Example-3: a = b = 1 a = 1; b = 1 a, b = 1, 2 Python does not have ++ AND -- operators
  • 5. OPERATORS Unary Minus Example-1: n = 10 print(-n) Example-2: num = -10 num = -num print(num)
  • 6. OPERATORS Relational Operator Example Result > a > b False >= a >= b False < a < b True <= a <= b True == a == b False != a != b True The results are obtained for the values of: a = 1 b = 2
  • 7. OPERATORS Relational: Chaining Example-1: x = 15 print(10< x < 20) Example-2: print(1 < 2 < 3 < 4)
  • 8. OPERATORS Logical Operator Example Result and a and b 2 or a or b 1 not not a False Short Circuit evaluation implies to Logical Operators If a = 100, b = 200 Example-1: if (a < b and b < c): print("Yes") else: print("No") Example-2: if (a > b or b < c): print("Yes") else: print("No")
  • 9. OPERATORS Boolean Operator Example Result and a and b False or a or b True not not a False If a = True, b = False Example-1: print(a and b) print(a or b) print(not a)
  • 10. OPERATORS Bitwise Operator Example Result ~ ~a 1111 0101(-11) & a & b 0000 1010(10) | a | b 0000 1011(11) ^ a ^ b 0000 0001(1) << a << 2 0010 1000(40) >> a >> 2 0000 0010(2) If a = 10(0000 1010), b = 11(0000 1011) In case of >> shifting, it preserves the sign of the number.
  • 11. OPERATORS Membership Operator Description in Returns True, if an item is found in the specified sequence not in Returns True, if an item is not found in the specified sequence Example-1: names = ["Ram", "Hari", "Thomas"] for i in names: print(i) Example-2: postal = {"Delhi": 110001, "Chennai": 600001, "Bangalore": 560001} for city in postal: print(city, postal[city])
  • 12. OPERATORS Identity Operator Description is Returns True, if ID of two objects are same is not Returns True, if ID of two objects are not same  Use to comapre the memory locations of two objects  id(): Is used to get the memory location ID Example-1: a = 25 b = 25 if (a is b): #This compares only the locations print("a and b are same")
  • 13. OPERATORS Identity  To compare two objects, use ‘==’ operator Example-1: a = [1, 2, 3, 4] b = [1, 2, 3, 4] if (a == b): print("Objects are same") else: print("Objects are not same")
  • 14. OPERATORS Precedence & Associativity Operator Name (expressions...), [expressions...], {key: value...}, {expressions...} Binding or tuple display, list display, dictionary display, set display x[index], x[index:index], x(arguments...), x.attribute Subscription, slicing, call, attribute reference ** Exponentiation +, -, ~ Positive, negative, bitwise NOT *, @, /, //, % Multiplication, matrix multiplication, division, floor division, remainder +, - Addition, Subraction <<, >> Bitwise Left, Right shift & Bitwise AND ^ Bitwise XOR | Bitwise OR in, not in, is, is not, <, <=, >, >=, !=, == Comparisons, including membership tests and identity tests not Boolean not and Boolean and or Boolean or if-else Conditional Expression lambda Lambda Expression All operators follow, Left – Right associativity, except ** which follows Right - Left
  • 15. Mathematical Functions Example-1: import math x = math.sqrt(16) Example-2: import math as m x = m.sqrt(16) Example-3: from math import sqrt x = sqrt(16) Example-4: from math import sqrt, factorial x = sqrt(16) y = factorial(5)