(a) Consider the following sequence of commands in Python: A = [500, 'miles'] B = A[:] C = [A[0] is B[0], A[1] is B[1]]
Posted: Sat May 14, 2022 4:29 pm
(a) Consider the following sequence of commands in Python: A = [500, 'miles'] B = A[:] C = [A[0] is B[0], A[1] is B[1]] [7 marks] Draw a schematic representation of the contents of program memory after executing these three commands, showing the data living on the stack and the heap and how these are related. A memory location containing a refer- ence to another memory location should be represented by an arrow, as in the examples in lectures. (b) Suppose now that the execution of the above commands is followed by the execution of B[1] = 'more' Draw a diagram for the new state of program memory. [3 marks]