Q:

Write a Python program to copy of a deque object and verify the shallow copying process.

0

 Write a Python program to copy of a deque object and verify the shallow copying process.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import collections
tup1 = (1,3,5,7,9)
dq1 = collections.deque(tup1)
dq2 = dq1.copy()
print("Content of dq1:")
print(dq1)
print("dq2 id:")
print(id(dq1))
print("\nContent of dq2:")
print(dq2)
print("dq2 id:")
print(id(dq2))
print("\nChecking the first element of dq1 and dq2 are shallow copies:")
print(id(dq1[0]))
print(id(dq2[0]))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now