0
Q:

how to convert decimal to binary python

a = 5
#this prints the value of "a" in binary
print(bin(a))
9
int(binaryString, 2)
2
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)
2
a=int(input())
print(bin(a)[::2])
0
format(decimal ,"b")
0
DecimalToBinary(num):
        if num > 1:
            DecimalToBinary(num // 2)
            print num % 2
-2

New to Communities?

Join the community