Thursday, 3 November 2016

Convert a number to BINARY DIGIT

d=1
bin=0
n=int(input("enter no.:"))
while(n!=0):
    r=n%2
    bin=r*d+bin
    d=d*10
    n=n//2
print(bin)

No comments:

Post a Comment