Python Bitwise operator

Bitwise type Of Operators

               & Binary AND operator

  This operator copies a bit to the result if it subsists in both VARIABLES.

                | Binary OR

  This operator copies a bit if it subsists in either of the two values.

                & Binary ^ Binary XOR

  This operator declares values from the right side to the left side.

                & Binary AND operator

  This operator copies the bit if it is set in one value or variable(operand) but not both.

            ~ Binary Ones Complement

  This operator is unary and has the impact of changing bits.

                << Binary Left Shift

  The left operand value is moved left by the number of bits as specified by the right value.

                >> Binary Right Shift

  The value of the left operand is shifted right by the number of bits as defined by the right values.

The bitwise operators in Python enable the programmers to check those precise bits of data at the usual granular level. All binary bitwise operators hold an identical compound operator that operates an augmented assignment.

Essentially each bitwise operator is binary, which symbolizes that they want two operands to operate with, typically pointed to as the left operand and the right one. The Bitwise NOT (~) is one of the unique unary bitwise operators after all it asks simply one operand to perform..

You know, bitwise operators. are displayed with a unique-looking symbol rather than words. This displays them in Python as somewhat less tedious than you might be practiced to seeing. You might not be prepared to infer their application simply by glancing at them..
Python departs you from the underlying bits with high-level ideas. You might see the overloaded features of bitwise operators while practicing. Although when you perform with them in their authentic form, you might be astounded by their characteristics!


a = 10 b = 4 # Print bitwise AND operation print("a & b =", a & b) # Print bitwise OR operation print("a | b =", a | b) # Print bitwise NOT operation print("~a =", ~a) # print bitwise XOR operation print("a ^ b =", a ^ b)


a & b = 0
a | b = 14
~a = -11
a ^ b = 14