answersLogoWhite

0

The Boolean OP1 AND OP2 operates bit-by-bit, setting a 1 in the result if the corresponding bit in OP1 and OP2 are both 1's. A similar operation is the Boolean OP1 OR OP2 which sets a 1 in the result of the corresponding bit in either OP1 or OP2 are both 1.

The number 5 is 101 in binary, while the number 4 is 100 in binary, so ANDing 5 and 4:

101

100

=

100

Since the "ones" bit is 1 in the number 5 and not in 4, it is zero in the result.

In Python the AND operator is "&", therefore in Python

a = 5 & 4

"a" will be 4.

User Avatar

Wiki User

12y ago

What else can I help you with?