Python Basic Tutorials

Python is a high level general purpose programming language which has a clear/easy learning curve. Python programming language is massively used in various domains like Artificial Intelligence, Data Science, Web Development, Utilities Tools and Scripts and many more

Python is a Programming language, and the default Python we use is written in C programming language which is also referred to as CPython (Python implementation in C). There are various implementation of Python Programming language i.e Jython(in JAVA), Skulpt(in JS) e.t.c

To make everything easy: We refer CPython as Python

Python Bitwise Operators

Bitwise operators are those operators which are used to perform the operation at the bit level. It is basically used to perform bit operations. All the operands are operated as binary strings.

For example, if you are performing or operation between 2 and 4 then the or operation will be in its bit level. i.e,

2 in binary = 0000 0010

3 in binary = 0000 0011

or operation: 0000 0010 | 0000 0011 = 0000 0011

and operation: 0000 0010 & 0000 0011 = 0000 0010

Operators Operator meanings Examples
& Bitwise and A & B
| Bitwise or A | B
~ Bitwise not(1's Complement) ~A, ~B
^ Bitwise xor A ^ B
>> Bitwise right shift A >> 2
<< Bitwise left shift B >> 2
Example program:

>>> a=1
>>> b=2
>>> a&b
    0
>>> a|b
    3
>>> ~a
    -2