2

I was doing a HandON with below Code:

for i in range(10,16):
    if(i%5==0 & i%3==0):
        print(i, 'both')
    elif i%5==0:
        print(i,'divisible by 5')
    elif i%3==0:
        print(i,'divisible by 3')

When I am executing this Code, it is giving Output as :

10 both
12 divisible by 3
15 both

Why is it giving 10 as divisible by both? If it is Bit-wise operator, then 'if' will have '0001' and '0000' for value 10, which should result in '0000'. If I use 'and' instead of '&', it is giving correct answer.

Gopesh
  • 195
  • 1
  • 3
  • 17

0 Answers0