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 127 views
1 answer 115 views
1 answer 155 views
1 answer 122 views
1 answer 109 views
...