Operators Part 2 - Python
Operators Part 2 - Python
Example:
n1 = 2
n2 = 3
num = n1 < n2
print(num)
4. Logical Operators
Logical operators are used to combine two or more condi3ons and perform the logical
opera3ons using logical AND, OR, NOT
Example:
a = 2 < 3 and 4 > 3
print(“value of a =”, a)
5. Bitwise Operators
Bitwise operator works on bits and performs bit by bit opera3on. Assume if a = 60; and b =
13; Now in the binary format their values will be 00111100 and 00001101 respec3vely.
Example
A=60
B=13
C=0
C= A & B
print (C)
6. Membership Operators
Python’s membership operators test for membership in a sequence, such as strings, lists, or
tuples.
Operator Meaning Example
in Evaluate to true if x in y, here in results in a 1 if x is member
it finds a variable in of sequence y.
the specified
sequence and false
otherwise
not in Evaluate to true if x not in y, here not in results in a 1 if x is
it does not finds a not a member of sequence y.
variable in the
specified sequence
and false otherwise
Example
A= 10
B = 20
List = [1, 2, 3, 4, 5];
If ( A in List ):
Print(“ A is available”);
else:
Print(“A is not available”)