How to print the bits of an integer in 16 bit format with Python

2 Answers

0 votes
num = 17

print(bin(num)[2:].zfill(16))




'''
run:

0000000000010001

'''

 



answered Jan 10, 2023 by avibootz
0 votes
num = 17
 
print('{:016b}'.format(num))
 
 
 
 
'''
run:
 
0000000000010001

 
'''

 



answered Dec 13, 2023 by avibootz

Related questions

1 answer 125 views
1 answer 112 views
1 answer 149 views
1 answer 118 views
1 answer 101 views
...