Pleasssssssssssseee answer this - Explain Membership operators & Identity operators in PYTHON.
Answers
Membership operators :-
These operators are used check whether the value/variable exist in a sequence or not.
• in : This operator returns True if a value exists in a sequence, False otherwise.
• not in : This operator returns True if a value does not exists in a sequence, False otherwise.
______________________
Identity operators :-
These operators are used to check if two values or objects belong to same memory location or refer to same instance in Python. They can be used in the following way :
• is : This operator returns True if both operands are identical, False otherwise.
# True as both variables refers to same value in
# the memory
# True as Python will create new reference of variable 'x'
# to value 3 on the same memory location
• is not : This operator returns True if both operands are not on same memory location, False otherwise.
# Though both lists are identical, they will not be stored
# at the same memory location as lists are mutable.
Answer: