def to_bin():
    n = int(input())
    lista = []
    i = 1
    while i <= n:
        lista.insert(0, i)
        i *= 2

    soluzione = ''
    for k in lista:
        if n >= k:
            soluzione += '1'
            n -= k
        else:
            soluzione += '0'
    
    print(soluzione)
    return int(soluzione)
    



def to_dec():
    n = str(input())
    soluzione = 0
    k = 0
    for i in n:
        soluzione += int(i)*(2**(len(n) -1 -k))
        k += 1

    print(soluzione)
    return soluzione

to_bin()
to_dec()

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: