SHARE
TWEET

Untitled

Galebickosikasa Oct 21st, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def to_ten(x, p):
  2.     x = str(x)
  3.     ans = 0
  4.     ns = 1
  5.     for i in range(len(x) - 1, -1, -1):
  6.         ans += int(x[i]) * ns
  7.         ns *= p
  8.  
  9.     return ans
  10.  
  11.  
  12. t = 1001100110
  13. print(to_ten(t, 2))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top