0

I am reviewing the logical operators in Python. What's the difference between the 'and' operator and the '&' operator?

It seems that '&' is doing a bitwise AND, like 10(1010) & 7(0111) result in 2(0010). But how does the 'and' actually work? Why does 10 & 7 result in 7 in this case? Many thanks in advance!

6
  • 2
    Please search before asking… Commented Aug 4, 2023 at 14:30
  • 10 & 7 is certainly not 7. Commented Aug 4, 2023 at 14:30
  • PSA: Wikipedia exists. Commented Aug 4, 2023 at 14:31
  • @tadman given the correct explanation in the sentence before I assume OP meant 10 and 7 Commented Aug 4, 2023 at 14:31
  • @mozway I see that in a correction now. Commented Aug 4, 2023 at 14:32

0