PYTHON CODING: binary to decimal

 PYTHON CODING: binary to decimal


                                                                    










PYTHON CODING: binary to decimal

full code:

def b_to_d(value):
    d=len(value)
    var=0
    o=1
    for i in range(0,d):
        k=d-o
        y=int(value[i])
        var_1=y*2**k
        o+=1
        var+=var_1
    return var


t=str(input('enter your binary value:   '))    #it should be the string datatype
u=b_to_d(t)
print('your decimal value is:  ',u)

output:

PYTHON CODING: binary to decimal



Post a Comment

0 Comments