What is vertical bar in Python bitwise assignment operator?



Vertical bar (|) stands for bitwise or operator. In case of two integer objects, it returns bitwise OR operation of two

>>> a=4
>>> bin(a)
'0b100'
>>> b=5
>>> bin(b)
'0b101'
>>> a|b
5
>>> c=a|b
>>> bin(c)
'0b101'
Updated on: 2020-03-02T09:53:31+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements