Chapter 2-8 using the transfer function (30) Python

Input and a binary integer, converted to decimal output

Input formats:
input and binary integer in a row

Output format:
The results in the output line of decimal

Sample input:
Here is given a set of inputs. For example:
45,8

Output Sample:
In the given here corresponding output. For example:
37

a,b=input().split(",")
a=int(a)
b=int(b)
s=0
i=0
while a>0:
    s=s+(a%10)*(b**i)
    i=i+1
    a=a//10
print(s)
Published 14 original articles · won praise 1 · views 91

Guess you like

Origin blog.csdn.net/weixin_45948920/article/details/104345712