I'm trying to convert integer to binary. This is my work. I don't know how the make a list to show the binary.
num_str = input("Please give me a integer: ")
num_int = int(num_str)
while num_int > 0:
if num_int % 2 == 0:
num_int = int(num_int / 2)
num_remainder = 1
print("The remainder is:", 0)
continue
elif num_int % 2 == 1:
num_int = int(num_int / 2)
num_remainder = 1
print("The remainder is:", 1)
continue
How to make the remainder together?
num_remainder
should be a string, then you concate the1
or0
to it. – bubuzzz Jan 30 '13 at 3:53