How do you express an integer as a binary number with Python literals?
I was easily able to find the answer for hex:
>>> 0x12AF
4783
>>> 0x100
256
and octal:
>>> 01267
695
>>> 0100
64
How do you use literals to express binary in Python?
Summary of Answers
int('01010101111',2)
but not with a literal.0b1100111
or 0B1100111
.0o27
or 0O27
(second character is the letter O) to represent an octal.027
syntax for octals.