Embercode
✕
References and MemoryQuick quiz

Diagrams and aliasing

8 questions. Covers Aliasing in Python.

Questions 1 to 5 of 8

  1. 1. What does this program print? ``python class Node: def __init__(self, value, next=None): self.value = value self.next = next c = Node(3) b = Node(2, c) a = Node(1, b) a.next = c print(a.value, a.next.value) print(b.value, b.next.value) ``
  2. 2. What does this program print? ``python grid = [[1, 1], [2, 2]] shallow = grid.copy() shallow[0][0] = 9 shallow[1] = [5, 5] print('grid =', grid) print('shallow =', shallow) ``
  3. 3. What does this program print? ``python base = ['x', 'y'] view = base snapshot = tuple(base) base[0] = 'q' print(view, snapshot) ``
  4. 4. In a picture of references, what does a.next = x change?
  5. 5. What does this program print? ``python a = [1, 2, 3] b = a print(a is b) ``

5 question(s) left on this page.