Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def to_ten(x, p):
- x = str(x)
- ans = 0
- ns = 1
- for i in range(len(x) - 1, -1, -1):
- ans += int(x[i]) * ns
- ns *= p
- return ans
- t = 1001100110
- print(to_ten(t, 2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement