Practice high-yield Programming & Software Development MCQs on Sets In Python — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following data types in Python is mutable and does not allow duplicate elements?
Correct Answer: Option A — Set
Detailed Academic Explanation:
Set is the correct answer to “Which of the following data types in Python is mutable and does not allow duplicate elements”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can you add an element to a set in Python?
Correct Answer: Option A — add()
Detailed Academic Explanation:
add() is the correct answer to “How can you add an element to a set in Python”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to remove an element from a set?
Correct Answer: Option A — remove()
Detailed Academic Explanation:
remove() is the correct answer to “Which method is used to remove an element from a set”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the len() function do when applied to a set or tuple?
Correct Answer: Option A — Returns the number of elements in the set or tuple
Detailed Academic Explanation:
Returns the number of elements in the set or tuple is the correct answer to “What does the len() function do when applied to a set or tuple”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the set() constructor in Python?
Correct Answer: Option A — Creates a new set
Detailed Academic Explanation:
Creates a new set is the correct answer to “What is the purpose of the set() constructor in Python”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the union() method for sets?
Correct Answer: Option A — Returns a new set with elements from both sets
Detailed Academic Explanation:
Returns a new set with elements from both sets is the correct answer to “What is the purpose of the union() method for sets”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, how can you check if an element exists in a set?
Correct Answer: Option A — in keyword
Detailed Academic Explanation:
in keyword is the correct answer to “In Python, how can you check if an element exists in a set”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What method is used to remove an element from a set without raising an error if the element is not present?
Correct Answer: Option A — discard()
Detailed Academic Explanation:
discard() is the correct answer to “What method is used to remove an element from a set without raising an error if the element is not present”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: my_set = {1, 2, 3} print(my_set)
Correct Answer: Option A — {1, 2, 3}
Detailed Academic Explanation:
{1, 2, 3} is the correct answer to “What is the output of the following code: my_set = {1, 2, 3} print(my_set)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: my_set = {1, 2, 3} my_set.add(4) print(my_set)
Correct Answer: Option B — {4, 1, 2, 3}
Detailed Academic Explanation:
{4, 1, 2, 3} is the correct answer to “What will be the output of the following code: my_set = {1, 2, 3} my_set.add(4) print(my_set)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: my_set = {1, 2, 3, 4, 5} my_set.pop() print(my_set)
Correct Answer: Option D — {2, 3, 4}
Detailed Academic Explanation:
{2, 3, 4} is the correct answer to “What is the output of the following code: my_set = {1, 2, 3, 4, 5} my_set.pop() print(my_set)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: my_set = {1, 2, 3} my_set.remove(2) print(my_set)
Correct Answer: Option B — {1, 3}
Detailed Academic Explanation:
{1, 3} is the correct answer to “What is the output of the following code: my_set = {1, 2, 3} my_set.remove(2) print(my_set)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to find the intersection of two sets?
Correct Answer: Option A — intersection()
Detailed Academic Explanation:
intersection() is the correct answer to “Which method is used to find the intersection of two sets”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: set1 = {1, 2, 3} set2 = {1, 2} print(set1.issuperset(set2))
Correct Answer: Option A — TRUE
Detailed Academic Explanation:
TRUE is the correct answer to “What is the output of the following code: set1 = {1, 2, 3} set2 = {1, 2} print(set1.issuperset(set2))”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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)
Correct Answer: Option C — False True
Detailed Academic Explanation:
False True is the correct answer to “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)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? s=set([1, 2, 3]) s.union([4, 5]) s|([4, 5])
Correct Answer: Option C — {1, 2, 3, 4, 5} Error
Detailed Academic Explanation:
{1, 2, 3, 4, 5} Error is the correct answer to “What will be the output of the following Python code snippet? s=set([1, 2, 3]) s.union([4, 5]) s|([4, 5])”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={3,4,5} >>> a.update([1,2,3]) >>> a
Correct Answer: Option B — {1, 2, 3, 4, 5}
Detailed Academic Explanation:
{1, 2, 3, 4, 5} is the correct answer to “What will be the output of the following Python code? >>> a={3,4,5} >>> a.update([1,2,3]) >>> a”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the clear() method for sets?
Correct Answer: Option A — Removes all elements from the set
Detailed Academic Explanation:
Removes all elements from the set is the correct answer to “What is the purpose of the clear() method for sets”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,8,9,10} >>> len(a+b)
Correct Answer: Option B — Error, unsupported operand '+' for sets
Detailed Academic Explanation:
Error, unsupported operand '+' for sets is the correct answer to “What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,8,9,10} >>> len(a+b)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If a={5,6,7,8}, which of the following statements is false?
Correct Answer: Option D — a[2]=45
Detailed Academic Explanation:
a[2]=45 is the correct answer to “If a={5,6,7,8}, which of the following statements is false”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> s={5,6} >>> s*3
Correct Answer: Option A — Error as unsupported operand type for set data type
Detailed Academic Explanation:
Error as unsupported operand type for set data type is the correct answer to “What will be the output of the following Python code? >>> s={5,6} >>> s*3”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, how can you check if two sets have no elements in common?
Correct Answer: Option A — isdisjoint()
Detailed Academic Explanation:
isdisjoint() is the correct answer to “In Python, how can you check if two sets have no elements in common”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? s={4>3, 0, 3-3} all(s) any(s)
Correct Answer: Option B — False True
Detailed Academic Explanation:
False True is the correct answer to “What will be the output of the following Python code? s={4>3, 0, 3-3} all(s) any(s)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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', 'p', 'q', 'xyz'} is the correct answer to “What will be the output of the following Python code snippet? z=set('abc') z.add('xyz') z.update(set(['p', 'q'])) z”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={5,6,7} >>> sum(a,5)
Correct Answer: Option B — 23
Detailed Academic Explanation:
23 is the correct answer to “What will be the output of the following Python code? >>> a={5,6,7} >>> sum(a,5)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x=set('abcde') y=set('xyzbd') x.difference_update(y) x y
{‘a’, ‘c’, ‘e’} {‘x’, ‘y’, ‘z’, ‘b’, ‘d’} is the correct answer to “What will be the output of the following Python code? x=set('abcde') y=set('xyzbd') x.difference_update(y) x y”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={1,2,3} >>> b=frozenset([3,4,5]) >>> a-b
Correct Answer: Option A — {1,2}
Detailed Academic Explanation:
{1,2} is the correct answer to “What will be the output of the following Python code? >>> a={1,2,3} >>> b=frozenset([3,4,5]) >>> a-b”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={1,2,3} >>> a.intersection_update({2,3,4,5}) >>> a
Correct Answer: Option A — {2,3}
Detailed Academic Explanation:
{2,3} is the correct answer to “What will be the output of the following Python code? >>> a={1,2,3} >>> a.intersection_update({2,3,4,5}) >>> a”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? l=[1, 2, 4, 5, 2, 'xy', 4] set(l) l
{1, 2, 4, 5, ‘xy’} [1, 2, 4, 5, 2, ‘xy’, 4] is the correct answer to “What will be the output of the following Python code snippet? l=[1, 2, 4, 5, 2, 'xy', 4] set(l) l”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the issuperset() method for sets?
Correct Answer: Option A — Checks if a set contains all elements of another set
Detailed Academic Explanation:
Checks if a set contains all elements of another set is the correct answer to “What is the purpose of the issuperset() method for sets”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Is the following Python code valid? >>> a=frozenset([5,6,7]) >>> a >>> a.add(5)
Correct Answer: Option B — No, frozen set is immutable
Detailed Academic Explanation:
No, frozen set is immutable is the correct answer to “Is the following Python code valid? >>> a=frozenset([5,6,7]) >>> a >>> a.add(5)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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)
{1, 2, 3, 4, 5, 6, 8} {1, 2, 3, 4, 5, 6, 8} is the correct answer to “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)”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these about a set is not true?
Correct Answer: Option D — Immutable data type
Detailed Academic Explanation:
Immutable data type is the correct answer to “Which of these about a set is not true”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? a=set('abc') b=set('def') b.intersection_update(a) a b
Correct Answer: Option C — {‘b’, ‘c’, ‘a’} set()
Detailed Academic Explanation:
{‘b’, ‘c’, ‘a’} set() is the correct answer to “What will be the output of the following Python code? a=set('abc') b=set('def') b.intersection_update(a) a b”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the intersection() method for sets?
Correct Answer: Option A — Returns a new set with elements common to both sets
Detailed Academic Explanation:
Returns a new set with elements common to both sets is the correct answer to “What is the purpose of the intersection() method for sets”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={1,2,3} >>> b=a >>> b.remove(3) >>> a
Correct Answer: Option C — {1,2}
Detailed Academic Explanation:
{1,2} is the correct answer to “What will be the output of the following Python code? >>> a={1,2,3} >>> b=a >>> b.remove(3) >>> a”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The . . . . . . . . function removes the first element of a set and the last element of a list.
Correct Answer: Option B — pop
Detailed Academic Explanation:
pop is the correct answer to “The . . . . . . . . function removes the first element of a set and the last element of a list.”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> a={4,5,6} >>> b={2,8,6} >>> a+b
Correct Answer: Option C — Error as unsupported operand type for sets
Detailed Academic Explanation:
Error as unsupported operand type for sets is the correct answer to “What will be the output of the following Python code? >>> a={4,5,6} >>> b={2,8,6} >>> a+b”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following lines of code will result in an error?
Correct Answer: Option D — s={exa}
Detailed Academic Explanation:
s={exa} is the correct answer to “Which of the following lines of code will result in an error”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following functions cannot be used on heterogeneous sets?
Correct Answer: Option D — sum
Detailed Academic Explanation:
sum is the correct answer to “Which of the following functions cannot be used on heterogeneous sets”. This question is standard in competitive examination syllabi for Sets In Python.
💡Key Conceptual Anchor:Sets In Python
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.