Explore topic-wise MCQs in Technical MCQs.

This section includes 10 Mcqs, each offering curated multiple-choice questions to sharpen your Technical MCQs knowledge and support exam preparation. Choose a topic below to get started.

1.

set1={1,2,3}
set1.add(4)
set1.add(4)
print(set1)
10.Which of the following options will give an error if set1={2,3,4,5}?

A. print(set1[0])
B. set1[0]=9
C. set1=set1+{7}
D. All of the above
E.
Answer» E.
2.

set1={2,3}
set2={3,2}
set3={2,1}
if(set1==set2):
print("yes")
else:
print("no")
if(set1==set3):
print("yes")
else:
print("no")
9.What will the be the result of below Python code?

A. {1,2,3,4}
B. {1,2,3}
C. {1,2,3,4,4}
D. It will throw an error as same element is added twice
Answer» B. {1,2,3}
3.

set1={2,3}
set2={3,2}
set3={2,1}
if(set1==set2):
print("yes")
else:
print("no")
if(set1==set3):
print("yes")
else:
print("no")

8.Suppose there are two sets, set1 and set2,where set1 is the superset of set2. It is required to get only the unique elements of both the sets. Which of the following will serve the purpose?

A. set1|set2
B. set1&set2
C. set1-set2
D. None of the above
Answer» D. None of the above
4.

set1={"a",3,"b",3}
set1.remove(3)
7.What will the below Python code do?

A. Yes, No
B. No, No
C. Yes, Yes
D. "==" is not supported for set in Python
Answer» B. No, No
5.

If set1={"a","b",3}set2={3,7}
6.What will the below Python code do?

A. It removes element with index position 3 from set1
B. It removes element 3 from set1
C. It removes only the first occurance of 3 from set1
D. No such function exists for set
Answer» C. It removes only the first occurance of 3 from set1
6.

list1=[1,3,4,2]
x=list1.pop(2)
print(set([x]))
5.What will set1|set2 do?

A. Elements of set2 will get appended to set1
B. Elements of set1 will get appended to set2
C. A new set will be created with the elements of both set1 and set2
D. A new set will be created with the unique elements of set1 and set2.
Answer» D. A new set will be created with the unique elements of set1 and set2.
7.

set1={2,5,3}
set2={3,1}
set3={}
set3=set1&set2
print(set3)
4.What will be the output of following Python code?

A. {1,3,4}
B. {1,3,2}
C. {2}
D. {4}
Answer» E.
8.

set1={0,0,9}
print(set1)
3.What will be the output of following Python code?

A. {3}
B. {}
C. {2,5,3,1}
D. {2,5,1}
Answer» B. {}
9.

What will be the output of following Python code?

A. {0,0,9}
B. {0,9}
C. {9}
D. It will throw an error as there are two 0 while creating the set.
Answer» C. {9}
10.

Which of the following Python code will create a set? (i) set1=set((0,9,0)) (ii) set1=set([0,2,9]) (iii) set1={}

A. iii
B. i and ii
C. ii, iii
D. All of the above
Answer» E.