Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CSC108H Fall 2023 Worksheet: Variable Assignment Memory Model

For each of the following code snippets, fill in the memory model diagram on the right to reflect the state of
memory after the code is executed. In each case, we begin with the state where a has already been assigned
the value 5. You may not need to use all of the boxes.
python's memory

id1:int
a id1 5
id2: int
a = 5 b
id2
b = 4
c = 6 4
c
id3 id3: int

id2
id1:int
a id1 5
int
a = 5 b id2
id2:
a = 3 x = 37
b = a 3 y = x +2
x = 20
id3: y= 39

j=2
id3 id1:int k = 10
j=k
5 k=j
a id1
j & k =10
b id2: int
a = 5
b = a + 2
id2
a = 10 7
int
id3:
10

You might also like