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?
here's my 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:]