samedi 12 septembre 2020

Don't understand why if (5 & 2): is False

This is a pretty trivial question that I haven't been able to find the answer to.

Here is the problem.

#1

if 3 & 2:
    print('True')
else:
    print('False')
#1 result = True

#2

if 5 & 2:
    print('True')
else:
    print('False')
#2 result = False

I think the reason is Bitwise operators, but I don't understand this situation.

Any clarification would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire