+ 2
I want to directly work with bits and do and an or on them how can i?
For example i want do this: Input 00101001 and 11111111 Output the and on it !
3 Answers
+ 3
Jason
may be it helps you
https://code.sololearn.com/cyB2jStmP8iu/?ref=app
+ 2
a=int(input())
b=int(input())
So you can input binary numbers like
0b00101001
0b11111111
and perform operations
For And
a&b
For or
a|b
+ 1
a = int(input(), 2) # <= input in binary e.g 00101001
b = int(input(), 2) # <= input in binary e.g 11111111
print(a & b)
print(bin(a & b))
print(bin(a & b)[2:])