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 211 views
1 answer 209 views
1 answer 233 views
1 answer 204 views
1 answer 201 views
...