fork download
  1. number = 12
  2. a = False
  3. myResult = ''
  4. for myCounter in range (8):
  5.  
  6. if (number % 2 == 1):#if remainder is equal to 1
  7. myResult = ' 1 ' + myResult#add '1' character to the string
  8.  
  9. else:
  10. (number % 2 == 0)#if input has no remainder
  11. myResult = ' 0 ' + myResult#add '0' character to the string
  12.  
  13. number = number // 2
  14.  
  15. print("Binary equivalent is: %s" %myResult)
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
Binary equivalent is:  0  0  0  0  1  1  0  0