(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]]
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
(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]]
(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]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!