When it comes to binary numbers, bitwise operators are the choice.

Bitwise operators are used to performing operations on binary numbers.

## AND, OR, XOR operators

- AND
`&`

operator sets each bit to 1 if both bits are 1. - OR
`|`

operator sets each bit to 1 if one of two bits is 1. - XOR
`^`

operator sets each bit to 1 if only one of two bits is 1. Output:

```
AND 82
OR 2039
XOR 1957
```

Ha Ha, surprised about the outputs?!

The outputs are a result of the binary numbers a and b which gets converted into an integer, each time bitwise operation is performed.

## NOT operator

- NOT
`~`

operator inverts all the bits. - In python, the number gets converted into an inverted
*signed*number. Output:

```
NOT -11
```

## Shift operators

- left shift
`<<`

operator shifts left by pushing zeros in from the right and let the leftmost bits fall off. - right shift
`>>`

operator shifts right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off. Output:

```
Right shift 277
Left shift 4444
```

### Best Resources

Python Blog Series : A Blog series where I will be learning and sharing my knowledge on each of the above topics.

Learn Python for Free, Get Hired, and (maybe) Change the World! : A detailed roadmap blog by Jayson Lennon (a Senior Software Engineer) with links to free resources.

**Zero To Mastery Course**- Complete Python Developer : A comprehensive course by Andrei Neagoie (a Senior Developer) that covers all of the above topics.

**Who Am I?**

I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging during the busy time of my freelancing work life. Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath

**Thank you** so much for reading my blog🙂.

## Top comments (2)

Thanks for sharing Aswin 😀

You're welcome bro.

Stay tuned for more bite sized knowledge😇.