Question 1 of 25
Hints left: 3
Q1
The following Python code results in an error. s={2, 3, 4, [5, 6]}
Q2
What will be the output of the following Python code? >>> a={1,2,3} >>> b=a >>> b.remove(3) >>> a
Q3
What will be the output of the following Python code? >>> s={5,6} >>> s*3
Q4
What will be the output of the following Python code snippet? l=[1, 2, 4, 5, 2, 'xy', 4] set(l) l
-
A
-
B
-
C
-
D
Q5
Which of these about a set is not true?
Q6
What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,8,9,10} >>> len(a+b)
Q7
What will be the output of the following Python code? >>> a={1,2,3} >>> b=frozenset([3,4,5]) >>> a-b
Q8
Is the following Python code valid? >>> a=frozenset([5,6,7]) >>> a >>> a.add(5)
Q9
What is the purpose of the intersection() method for sets?
Q10
What will be the output of the following Python code snippet? z=set('abc') z.add('xyz') z.update(set(['p', 'q'])) z
-
A
-
B
-
C
-
D
Q11
What will be the output of the following Python code? s={4>3, 0, 3-3} all(s) any(s)
Q12
If a={5,6,7,8}, which of the following statements is false?
Q13
Which of the following functions cannot be used on heterogeneous sets?
Q14
Which of the following is not the correct syntax for creating a set?
-
A
-
B
-
C
-
D
Q15
What will be the output of the following Python code? >>> a={5,6,7} >>> sum(a,5)
Q16
In Python, how can you check if two sets have no elements in common?
Q17
The . . . . . . . . function removes the first element of a set and the last element of a list.
Q18
What will be the output of the following Python code? >>> a={1,2,3} >>> a.intersection_update({2,3,4,5}) >>> a
Q19
What is the purpose of the issuperset() method for sets?
Q20
What will be the output of the following Python code? a=set('abc') b=set('def') b.intersection_update(a) a b
Q21
What will be the output of the following Python code? x=set('abcde') y=set('xyzbd') x.difference_update(y) x y
-
A
-
B
-
C
-
D
Q22
Which of the following lines of code will result in an error?
Q23
In Python, how can you check if two sets have no elements in common?
Q24
What will be the output of the following Python code? s1={1, 2, 3, 8} s2={3, 4, 5, 6} s1|s2 s1.union(s2)
-
A
-
B
-
C
-
D
Q25
What will be the output of the following Python code? >>> a={4,5,6} >>> b={2,8,6} >>> a+b