What is the difference of the below two codes?


#1

WORKING CODE:

def check_bit4(i):
num = 0b1000
f = num & i
if f > 0:
return "on"
else:
return "off"
print check_bit4(0b1100)

NOT WRONG CODE:

def check_bit4(i):
num = 0b1000
f = num & i
if f > 0:
return "on"
else:
return "off"
print check_bit4(bin(9))


#2

You don't have to use bin() method because of it already identifies numbers as binary code.

print check_bit4(9)

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.