Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 3 : [1, 2, 9] / [1, 2, 9]
Advertisement
Detailed Solution
सही उत्तर [1, 2, 9] / [1, 2, 9] है।
Key Points
Helpful?
Question:
What is the output of the following Python code involving a shallow copy of a nested list? / नेस्टेड सूची की उथली प्रति वाले निम्नलिखित Python कोड का आउटपुट क्या होगा? import copy a = [[1, 2], [3, 4]] b = copy.copy(a) b[0].append(9) print(a[0])
1.
[1, 2] / [1, 2]
2.
[3, 4] / [3, 4]
3.
[1, 2, 9] / [1, 2, 9]
4.
AttributeError / AttributeError
Correct Answer: [1, 2, 9] / [1, 2, 9]
copy.copy creates a shallow copy, so the inner lists are shared; appending to b[0] also changes a[0]. / copy.copy उथली प्रति बनाता है, इसलिए भीतरी सूचियाँ साझा रहती हैं; b[0] में जोड़ने से a[0] भी बदलता है।
Downloaded from PrepSnap (prepsnap.in)