Bitwise Operators in python [What are bitwise operators in Python?]

&ANDSets each bit to 1 if both bits are 1
|ORSets each bit to 1 if one of two bits is 1
 ^XORSets each bit to 1 if only one of two bits is 1
~NOTInverts all the bits
<<Zero fill left shiftShift left by pushing zeros in from the right and let the leftmost bits fall off
>>Signed right shiftShift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
# Bitwise operators
a = 10
b = 4

# AND operation
print(a & b)

# OR operation
print(a | b)

#  NOT operation

#  XOR operation
print(a ^ b)

# right shift operation
print(a >> 2)

# left shift operation
print(a << 2)



bitwise operators in python,
What are bitwise operators in Python?
What is bitwise operator example?
What are bitwise operators used for?
Which is a bitwise operator?
bitwise operators in python exercises,
bitwise operator in python w3schools,
logical and bitwise operators in python,
bitwise not operator in python,
bitwise xor operator in python,
bitwise operators in python ppt,
bitwise right shift operator in python,
bitwise left and right shift operator in python,

Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *