In python, you can only create it as a binary value (as syntactic sugar), it is immediately converted to an integer. Try it yourself:
>>> 0b11001010 202
The same thing will happen with octal and hexadecimal values. This way you can convert the binary string to an integer with the int() function base argument, for example:
>>> int('0b11001010', 2) 202
After the conversion, you can perform any operation on it - just like with an integer, since it is an integer.
Of course, you can convert it to a binary string at any time with the bin() function built in:
>>> bin(202) 0b11001010
source share