+ 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 !

16th May 2020, 8:56 PM
Jason
Jason - avatar
3 ответов
16th May 2020, 10:18 PM
Petr
+ 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
16th May 2020, 9:03 PM
Abhay
Abhay - avatar
+ 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:])
17th May 2020, 9:40 AM
rodwynnejones
rodwynnejones - avatar