2 comments:

  1. n=int(raw_input("enter number"))
    i=0
    s=0
    while (n>0):
    r=n%2
    s=s+pow(10,i)*r
    n=n/2
    i=i+1
    print s
    enter number123
    1111011

    ReplyDelete
  2. n=int(input('please enter the no. in decimal format: '))
    x=n
    k=[]
    while (n>0):
    a=int(float(n%2))
    k.append(a)
    n=(n-a)/2
    k.append(0)
    string=""
    for j in k[::-1]:
    string=string+str(j)
    print('The binary no. for %d is %s'%(x, string))

    ReplyDelete