PYthon Class 9 Telugu

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

~(complement) Operator

=======================

>>> print(~5)
-6
>>>
>>> print(~-9)
8
>>>
>>>
>>> print(~10)
-11
>>> print(~-13)
12
>>>
>>>
>>> print(10>>2)
2
>>>
>>> print(10<<2)
40
>>>
>>>
>>> print(True & True)
True
>>> print(True & False)
False
>>> print(False & True)
False
>>> print(False & False)
False
>>>
>>>
>>> print(True | True)
True
>>> print(True | False)
True
>>> print(False | True)
True
>>> print(False | False)
False
>>>
>>>
>>> print(True ^ True)
False
>>> print(False ^ False)
False
>>> print(True ^ False)
True
>>> print(False ^ True)
True
>>>
>>>
>>> print(~True)
-2
>>>
>>> print(True<<2)
4
>>>
>>> print(True>>2)
0
>>>
>>>

if x=10 then

1. x+5 ==> 15
2. x+=5 ==> x=x+5 ==> x=15

eg:

>>> x=10
>>> x+=5
>>> print(x)
15
>>>

Conditional Operators or Ternary Operators


===============================================

>>> a,b=100,200
>>> x=300 if a<b else 400
>>> print(x)
300
>>>
>>> x=300 if a>b else 400
>>>

Member ship Operators


==========================

>>> x="Welcome to Python Programming By Real Time Experts"


>>> print("Python" in x)
True
>>>
>>> print("Hello" in x)
False
>>>
>>> print("Python" not in x)
False
>>>
>>> print("Hello" not in x)
True

Identity Operators
=========================

>>> x=100
>>> y=100
>>>
>>> id(x)
2137890575824
>>> id(y)
2137890575824
>>>
>>>
>>>
>>> print(x is y)
True
>>>
>>> print(x is not y)
False
>>>
>>>
>>> x=10
>>> y=20
>>> id(x)
2137890384464
>>> id(y)
2137890384784

You might also like