title: how to convert decimal to two's complement with python?this is my program code, is there any other way to code it?
body: <p>I'm a beginner here. I'm trying to specify convert decimal to two's complement . Is there a way that I can shorten this code without using this code?</p>
  <p>here's my code</p>
  <pre class="lang-py prettyprint-override"><code>inputNum = random.randint(2,100)
  angkaku = bin(inputNum)
  string_angkaku = '{0:b}'.format(int(inputNum))
  number = int(string_angkaku,2)
  two_comp = (1)*(255 + 1 - number)
  slicing_tc = bin(two_comp)[2:]
  </code></pre>