Answers for "conversin to binary in python"

1

convert number to binary in python

bin(6)[2:]  
'110'

# bin() converts to binary, but leaves 0b as the start of the string, remove it
Posted by: Guest on September-06-2021
3

decimal to binary in python

a = 10
#this will print a in binary
bnr = bin(a).replace('0b','')
x = bnr[::-1] #this reverses an array
while len(x) < 8:
    x += '0'
bnr = x[::-1]
print(bnr)
Posted by: Guest on June-02-2020

Python Answers by Framework

Browse Popular Code Answers by Language