def dec_to_bin(n): ans = 0 f = 0 n = int(n) while (n != 0): ans += ((10 ** f) * (n % 2)) n = n // 2 f += 1 return ans def bin_to_dec(n): ans = 0 f = 0 n = int(n) while (n != 0): ans += ((2 ** f) * (n % 10)) n = n // 10 f += 1 return ans def oct_to_dec(n): ans = 0 f = 0 n = int(n) while (n != 0): ans += ((8 ** f) * (n % 10)) n = n // 10 f += 1 return ans def hex_to_dec(n): ans = 0 f = 0 n = int(n) while(n != 0): x = n % 10 x2 = 0 p2 = 0 while(x > 0): x2 += (x % 2) * (10 ** p2) x = x // 2 p2 += 1 ans += x2 * (1000 ** f) n = n // 10 f += 1 print(ans) return bin_to_dec(ans) * 2