Basically, in bitwise operations, we look at each individual bit rather than the whole binary representation of the number.
Let’s come to the code.
num1 = 01010 and num2 = 10100
The & operator represents the logical AND which means 1&0 would be 0.
num1 & num2 means that the AND operation will be performed between their bits:
01010
10100
Let’s start from the right side:
01010
10100
0&0 is 0.
01010
10100
1&0 is 0.
01010
10100
0&1 is 0
And so forth. The answer ultimately ends up being 0.