Question 1 of 25
Hints left: 3
Q1
What method is used to find the elements that are present in either of the sets, but not in both sets?
Q2
What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,5,6,8} >>> a==b
Q3
What will be the output of the following Python code, if s1= {1, 2, 3}? s1.issubset(s1)
Q4
Input order is preserved in sets.
Q5
In Python, how can you check if a set is a subset of another set?
Q6
What will be the output of the following Python code? >>> a={5,4} >>> b={1,2,4,5} >>> a<b
Q7
What will be the output of the following Python code? >>> a={1,2,3} >>> b=a.copy() >>> b.add(4) >>> a
Q8
What will be the output of the following Python code? s=set() type(s)
Q9
Write a list comprehension for number and its cube for: l=[1, 2, 3, 4, 5, 6, 7, 8, 9]
Q10
Which of these about a frozenset is not true?
Q11
What will be the output of the following Python code snippet? z=set('abc$de') 'a' in z
Q12
What is the syntax of the following Python code? >>> a=frozenset(set([5,6,7])) >>> a
Q13
What will be the output of the following Python code? >>> a={1,2,3} >>> {x*2 for x in a|{4,5}}
Q14
What is the output of the following code: set1 = {1, 2} set2 = {1, 2, 3, 4} print(set1.issubset(set2))
Q15
What will be the output of the following Python function? {x for x in 'abc'} {x*3 for x in 'abc'}
Q16
Is the following Python code valid? a={3,4,{7,5}} print(a[2][0])
Q17
What is the output of the following code: set1 = {1, 2, 3} set2 = {2, 3, 4} print(set1.difference(set2))
Q18
What will be the output of the following code: my_set = {1, 2, 3} new_set = my_set.copy() print(new_set)
-
A
-
B
-
C
-
D
Q19
What is the purpose of the difference() method for sets?
Q20
What is the purpose of the copy() method for sets?
Q21
What will be the output of the following Python code? s1={1, 2, 3} s2={4, 5, 6} s1.isdisjoint(s2) s2.isdisjoint(s1)
Q22
What will be the output of the following Python code? s1={3, 4} s2={1, 2} s3=set() i=0 j=0 for i in s1: for j in s2: s3.add((i,j)) i+=1 j+=1 print(s3)
-
A
-
B
-
C
-
D
Q23
If we have two sets, s1 and s2, and we want to check if all the elements of s1 are present in s2 or not, we can use the function:
Q24
The difference between the functions discard and remove is that:
Q25
What will be the output of the following Python code snippet? {a**2 for a in range(4)}
-
A
-
B
-
C
-
D