H Huyền Thu New member Sep 20, 2021 #1 What will be the output of the following Python code? Code: >>> a={1,2,3} >>> b=a.copy() >>> b.add(4) >>> a A. {1,2,3} B. Error, invalid syntax for add C. {1,2,3,4} D. Error, copying of sets isn’t allowed
What will be the output of the following Python code? Code: >>> a={1,2,3} >>> b=a.copy() >>> b.add(4) >>> a A. {1,2,3} B. Error, invalid syntax for add C. {1,2,3,4} D. Error, copying of sets isn’t allowed
M Minh Phượng New member Sep 20, 2021 #2 Answer: a Explanation: In the above piece of code, b is barely a copy and not an alias of a. Hence any change made in b isn’t reflected in a. Upvote 0 Downvote
Answer: a Explanation: In the above piece of code, b is barely a copy and not an alias of a. Hence any change made in b isn’t reflected in a.