Bitwise AND Operator (&)


Bitwise AND Operator

Bitwise AND Operator is used to perform AND operation between two given operands at bit level.

Symbol

The symbol of bitwise AND operator is &.

Syntax

The syntax to do bitwise AND operation between the operands: x and y, is

x & y

Example

The following is a simple example of how bitwise AND operation is done between two numbers.

x = 5
y = 20

#bit level
    x = 00000101
    y = 00010100
x & y = 00000100

Therefore x & y = 4

In this following program, we take integer values in x, and y, and perform bitwise AND operation between them.

Python Program

x = 5
y = 20
output = x & y
print(f'{x} & {y} = {output}')

Output

5 & 20 = 4

Summary

In this tutorial of Python Examples, we learned about Bitwise AND Operator, and it's usage with the help of examples.