Report Bug

Qus

Is the following Python code valid?

a={3,4,{7,5}}
print(a[2][0])
Qus

निम्नलिखित Python कोड वैलिड है?

a={3,4,{7,5}}
print(a[2][0])


A. Yes, 7 is printed
B. Error, elements of a set can’t be printed
C. Error, subsets aren’t allowed
D. Yes, {7,5} is printed


Solution
C. Error, subsets aren’t allowed



Explanation
In python, elements of a set must not be mutable and sets are mutable. Thus, subsets can’t exist.
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