Write a Python program to copy of a deque object and verify the shallow copying process.
- برمجة
- برمجة بايثون
- 2021-04-16
- salsabeelalhams99111801528
الأجوبة
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]))أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال