Question 1 of 25
Hints left: 3
Q1
Is the following Python code valid? a={1,2,3} b={1,2,3,4} c=a.issuperset(b) print(c)
Q2
What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,8,10,11} >>> a^b
Q3
What will be the output of the following Python code? a={1,2,3} b={1,2,3} c=a.issubset(b) print(c)
Q4
The output of the following code is: class<'set'>. type({})
Q5
What method is used to check if a key exists in a dictionary, and if not, add it with a default value?
Q6
Which of the following data types in Python is used to store key-value pairs?
Q7
What will be the output of the following Python code? nums = set([1,1,2,3,3,3,4,4]) print(len(nums))
Q8
What will be the output of the following Python code? >>> a={4,5,6} >>> b={2,8,6} >>> a-b
Q9
What will be the output of the following Python code? >>> a={1,2,3} >>> b=a.add(4) >>> b
Q10
What will be the output of the following Python code? s1={1, 2, 3} s2={3, 4, 5, 6} s1.difference(s2) s2.difference(s1)
-
A
-
B
-
C
-
D
Q11
What will be the output of the following Python code? a = [5,5,6,7,7,7] b = set(a) def test(lst): if lst in b: return 1 else: return 0 for i in filter(test, a): print(i,end=" ")
Q12
Set makes use of . . . . . . . . Dictionary makes use of . . . . . . . .
Q13
What does the len() function do when applied to a dictionary?
Q14
Which of the following statements is used to create an empty set?
Q15
What will be the output of the following Python code snippet? for x in set('pqr'): print(x*2)
Q16
What is the output of the following code: set1 = {1, 2, 3} set2 = {3, 4, 5} print(set1.union(set2))
-
A
-
B
-
C
-
D
Q17
Set members must not be hashable.
Q18
If a={5,6,7}, what happens when a.add(5) is executed?
Q19
Which method is used to find the symmetric difference between two sets?
Q20
Which of the following functions will return the symmetric difference between two sets, x and y?
Q21
What will be the output of the following Python code? s={1, 2, 3} s.update(4) s
Q22
What will be the output of the following Python code? s={2, 5, 6, 6, 7} s
Q23
In Python, how can you create an empty set?
Q24
What will be the output of the following Python code? >>> a={3,4,5} >>> b={5,6,7} >>> a|b
Q25
What will be the output of the following code: set1 = {1, 2, 3} set2 = {3, 4, 5} print(set1.intersection(set2))