How can i loop through a decimal number and print out a binary figure for that decimal number. This is the code i tried using python
dec_Num = 1200
for i in dec_Num;
print i
How can i loop through a decimal number and print out a binary figure for that decimal number. This is the code i tried using python
dec_Num = 1200
for i in dec_Num;
print i
Because the goal is to print we can generate a string
def DecimalToBinary(num):
strin=""
while num >= 1:
strin+=str(num%2)
num=num // 2
return strin[::-1]