Embercode
✕
References and MemoryQuick quiz

Memory mixed review

6 questions. Covers Aliasing in Python.

Questions 1 to 5 of 6

  1. 1. What does this program print? ``python import copy a = [[1], [2]] b = a[:] c = copy.deepcopy(a) a[0].append(9) print(b, c) ``
  2. 2. What does this program print? ``python rows = 3 cols = 4 flat = [0] * (rows * cols) for r in range(rows): for c in range(cols): flat[r * cols + c] = r * 10 + c r = 0 c = 1 print(flat[r * cols + c], 'then', flat[c * cols + r]) ``
  3. 3. A list holds 1 -> 2 -> 3. head refers to node 1, and b refers to node 2. The code below runs. What happens to node 2? ``python head.next = head.next.next ``
  4. 4. The variable name may be None. Which line is safe to run when name is None?
  5. 5. Match each Python exception to what it means.

    Choose the matching item for each row.

5 question(s) left on this page.