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.
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad