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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz