Question: Q1 For each snippet of code below, draw a rough memory model diagram of the state of each variable involved at the end of the
Q1 For each snippet of code below, draw a rough memory model diagram of the state of each variable involved at the end of the code snippet. (Note: For the ID numbers, you can just make up any numbers.)
example:

a)
>>> lst1 = [1, 3]
>>> lst2 = lst1[:]
>>> lst2.append(5)
b)
>>> lst1 = [1, 3]
>>> lst2 = lst1
>>> lst1.append(5)
>>> lst1 = [0]
c)
>>> a = [[1, 2, 3], ['a', 'b']]
>>> b = a
>>> b.append(99)
d)
>>> a = [[1, 2, 3], ['a', 'b']]
>>> b = a[:]
>>> b.append(99)
e)
>>> a = [[1, 2, 3], ['a', 'b']]
>>> b = a[:]
>>> b[0].append(99)
L = [[1, 2], [3, 4], [5, 6]] for item in : item[1] = 88 print(L) id22 1,88 id58 id23 3, 88 item id24 id 24 5, 88 id58 [id22, id23, id 24 ] Output: [[1,88] , [3, 88], [5, 88]] L = [[1, 2], [3, 4], [5, 6]] for item in : item[1] = 88 print(L) id22 1,88 id58 id23 3, 88 item id24 id 24 5, 88 id58 [id22, id23, id 24 ] Output: [[1,88] , [3, 88], [5, 88]]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
