Try it here
Subscribe
Python Operators

Operators in Python

operators_in_python

Membership Operators

Python membership operators test for membership in a sequence or an iterable such as strings, lists or tuples.

in ->

Evaluates to true if it finds a variable in the specified sequence and false otherwise.

not in ->

Evaluates to true if it does not find a variable in the specified sequence and false otherwise.

Example:

>>> 'op' in 'Python operators'
True
>>> 'op' not in 'Python operators'
False
>>> 5 in range(10)
True
>>> 7 not in range(10)
False
>>> 

Identity Operator

is ->

Evaluates to true if the variables on either side of the operator points to the same object and false otherwise.

is not ->

Evaluates to false if the variables on either side of the operator points to the same object and true otherwise.

>>> name="dEexams"
>>> name is "dEexams"
True
>>> name1=["a","b","c"]
>>> name2=name1
>>> name1 is name2
True
>>> name1 is not name2
False
>>> 

Writer profile pic

Aditya on Apr 21, 2020 at 12:04 am


This article is contributed by Aditya. If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.



Post Comment

Comments( 0)

WEB TECHNOLOGY

Articles

×

Forgot Password

Please enter your email address below and we will send you information to change your password.