Convert to binary and keep leading zeros
Use the format() function: >>> format(14, ‘#010b’) ‘0b00001110’ The format() function simply formats the input following the Format Specification mini language. The # makes the format include the 0b prefix, and the 010 size formats the output to fit in 10 characters width, with 0 padding; 2 characters for the 0b prefix, the other 8 … Read more