Page 181 - Ai_V3.0_c11_flipbook
P. 181
Bitwise XOR: 12
Bitwise NOT: -11
Bitwise Left Shift: 40
Bitwise Right Shift: 2
Reboot
Answer the following questions:
a. Name any two keywords in Python.
b. What is a token?
c. Which operator is used to represent exponent in Python?
d. Which operator returns the quotient after division as an integer?
Membership Operators
Membership operators are used to test whether a value is present in a sequence (such as a string, list, tuple, etc.) or not.
Operator Description
in Returns True if a specific value is present in a sequence
not in Returns True if a specific value is not present in a sequence
Program 10: To demonstrate the use of membership operators
# Uses of Membership Operators
# in operator
my_list = [1, 2, 3, 4, 5]
print("Is 3 in the list?", 3 in my_list)
# not in operator
print("Is 6 not in the list?", 6 not in my_list)
Output:
Is 3 in the list? True
Is 6 not in the list? True
Identity Operators
Identity operators are used to compare the memory locations of two objects rather than their values.
Operator Description
is Returns True if both variables are the same object in the memory.
is not Returns True if both variables are not the same object in the memory.
Python Programming 179

