As the preceding answers mostly used format(),here is an f-string implementation.
integer = 7bit_count = 5print(f'{integer:0{bit_count}b}')
Output:
00111
For convenience here is the python docs link for formatted string literals: https://docs.python.org/3/reference/lexical_analysis.html#f-strings.