Q:

Understanding output of logical AND exercise

I am working on an exercise with the instructions:

Write a program that performs Logical AND operation on two numbers.

and accompanied is this example of input and output:
Enter the 1st number:12
Enter the 2nd number:6
Result is 4

I do not understand how an AND comparison of these two numbers returns the output of 4. I keep thinking the output couldn't be anything other than 0, as the two numbers are not the same.

A:

Question is badly written; they mean bitwise and (&).
>>> print(12 & 6)
4

To understand why, you must look at the binary values:
  1100     (12)
  0110     ( 6)
& ----
  0100     ( 4)

