Embercode
✕
ArraysQuick quiz

Jagged arrays and copies

6 questions. Covers Jagged lists and copying in Python.

Questions 1 to 5 of 6

  1. 1. What does this program print? ``python def deep_copy(source): return [row[:] for row in source] a = [[1, 2], [3, 4, 5]] b = deep_copy(a) a[1][2] = 0 print(b[1][2]) ``
  2. 2. What does this program print? ``python x = [[1], [2]] y = [[1], [2]] print(x == y, x[0] is y[0]) ``
  3. 3. True or false: after grid = [None] * 3, the value of grid[1] is None.
  4. 4. True or false: after c = a.copy(), setting c[1][1] = 0 leaves a[1][1] unchanged.
  5. 5. What does this program print? ``python shared = [[0, 0]] * 2 shared[0][1] = 9 print(shared) ``

5 question(s) left on this page.