0% found this document useful (0 votes)
3 views

2.PYTHON Operators

python operators

Uploaded by

ANU JAYAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

2.PYTHON Operators

python operators

Uploaded by

ANU JAYAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

ALGORITHMIC

THINKING WITH
PYTHON
PYTHON OPERATORS
OPERATORS IN PYTHON

• Arithmetic Operators
• Comparison (Relational) Operators
• Assignment Operators
• Logical Operators
• Bitwise Operators
• Membership Operators
• Identity Operators
ASSIGNMENT OPERATORS
MEMBERSHIP OPERATOR

• in – Evaluates to True if it finds the item in the specified sequence and False
otherwise.
• not in – Evaluates to True if it does not find the item in the specified sequence
and False otherwise.
EXAMPLE PROGRAM- PREDICT THE OUTPUT

#membership operator
ourword='asadsdadsada'
print('d' in ourword)
print('o' in ourword)
print('a' not in ourword)
print('a' in 'Hello')
IDENTITY OPERATOR

• To check two values (or variables) are located in the same part of the memory.
• is- x is y evaluates to true if and only if x and y are the same object.
• is not - x is not y yields the inverse truth value
#identity operator
x=1
y=1.0
print(x is y)
print(x is not y)
print(id(x))
print(id(y))
x=y
print(x is y)
print(x is not y)
print(id(x))
print(id(y))
PRECEDENCE RULES IN PYTHON
• When an expression contains more than one operator, in what order will the
operations be performed?
#identity operator
x=1
y=1.0
print(x is y)
print(x is not y)
print(id(x))
print(id(y))
x=y
print(x is y)
print(x is not y)
print(id(x))
print(id(y))

You might also like