Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code? >>>t = (1, 2, 4, 3, 8, 9) >>>[t[i] for i in range(0, len(t), 2)]
-
A
-
B
-
C
-
D
Q2
What will be the output of the following Python code? >>>t=(1,2,4,3) >>>t[1:3]
Q3
What is the output of the following code: set1 = {1, 2, 3} set2 = {1, 2} print(set1.issuperset(set2))
Q4
What is the purpose of the clear() method for sets?
Q5
What will be the output of the following Python code snippet? a=[1, 4, 3, 5, 2] b=[3, 1, 5, 2, 4] a==b set(a)==set(b)
Q6
What is the purpose of the set() constructor in Python?
Q7
Is the following Python code valid? >>> a=(1,2,3) >>> b=a.update(4,)
-
A
-
B
-
C
-
D
Q8
What will be the output of the following Python code snippet? s=set([1, 2, 3]) s.union([4, 5]) s|([4, 5])
-
A
-
B
-
C
-
D
Q9
Which of the following data types in Python is mutable and does not allow duplicate elements?
Q10
What will be the output of the following code: my_set = {1, 2, 3} my_set.add(4) print(my_set)
-
A
-
B
-
C
-
D
Q11
Which method is used to remove an element from a set?
Q12
How can you add an element to a set in Python?
Q13
What is the purpose of the union() method for sets?
Q14
Is the following Python code valid? >>> a=2,3,4,5 >>> a
-
A
-
B
-
C
-
D
Q15
What will be the output of the following Python code? >>> a=(1,2,(4,5)) >>> b=(1,2,(3,4)) >>> a<b
Q16
Which method is used to find the intersection of two sets?
Q17
What does the len() function do when applied to a set or tuple?
Q18
What is the output of the following code: my_set = {1, 2, 3} my_set.remove(2) print(my_set)
Q19
What is the output of the following code: my_set = {1, 2, 3, 4, 5} my_set.pop() print(my_set)
-
A
-
B
-
C
-
D
Q20
What is the output of the following code: my_set = {1, 2, 3} print(my_set)
Q21
What will be the output of the following Python code? >>> a={3,4,5} >>> a.update([1,2,3]) >>> a
Q22
What will be the output of the following Python code? >>> a=(1,2) >>> b=(3,4) >>> c=a+b >>> c
Q23
What method is used to remove an element from a set without raising an error if the element is not present?
Q24
Is the following Python code valid? >>> a,b=1,2,3
Q25
In Python, how can you check if an element exists in a set?