n2 = input("Enter the second binary number: ")
n1 = int(n1,2)
n2 = int(n2,2)
bit_or = n1 | n2
bit_and = n1 & n2
bit_xor = n1 ^ n2
print("Result of OR: %10s" % bin(bit_or))
print("Result of AND: %10s" % bin(bit_and))
print("Result of XOR: %10s" % bin(bit_xor))
Result:
Enter a binary number: 10100
Enter the second binary number: 10001
Result of OR: 0b10101
Result of AND: 0b10000
Result of XOR: 0b101 ```
**Guys, please, help me to figure out what does "b" mean in the results with or, and, xor?**
It means that’s a binary number.
does it always follow the first sumber in result? As it is in 0b10101
The 0b
means it’s binary. That 0
before the b
is not the first number – all number base prefixes start with a 0
. Like 0x
for hex. What comes after the letter is the actual number.