school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

test.py (411B)


      1 def tostring(list):
      2         string = ""
      3         for i in list:
      4                 string += str(i)
      5         print(string)
      6 
      7 def getbin(n):
      8         out = []
      9         while (n >= 1):
     10                 out.append(n % 2)
     11                 n = int(n / 2)
     12 
     13         out.reverse()
     14         return out
     15 
     16 def tobin(n):
     17         raw = getbin(n)
     18         tostring(raw)
     19 
     20 n = int(input("what number would you like to convert: "))
     21 tobin(n)