Report Bug

Qus

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=a.copy()  >>> b.add(4) 

>>> a

Qusनिम्नलिखित पायथन कोड का आउटपुट क्या होगा?


A. {1,2,3}
B. Error, invalid syntax for add
C. {1,2,3,4}
D. Error, copying of sets isn’t allowed


Solution
A. {1,2,3}



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.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad