# Below are my solutions. # After that is code that I used to grade your assignment. # If you had an import statement or the code would not run due to error, you get a 0. # Otherwise, I ran 5 test cases. # You got 3 points per successful case. def binary(n): """Compute the binary representation of n as a list of bits.""" l = [] while n > 0: l = [n%2] + l n = n//2 return l def testbin(): test = [2, 3719839, 1125899906842624, 1023, 1] answer = [[1, 0], [1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1]] c = 0 for i in range(5): if binary(test[i]) == answer[i]: c += 3 return c