Skip to main content

Sets In Python — Part 1 MCQs with Explanations

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
Question 1 of 40
★ FPSC ★ PPSC

Which of the following data types in Python is mutable and does not allow duplicate elements?

Question 2 of 40
★ FPSC ★ PPSC

How can you add an element to a set in Python?

Question 3 of 40
★ FPSC ★ PPSC

Which method is used to remove an element from a set?

Question 4 of 40
★ FPSC ★ PPSC

What does the len() function do when applied to a set or tuple?

Question 5 of 40
★ FPSC ★ PPSC

What is the purpose of the set() constructor in Python?

Question 6 of 40
★ FPSC ★ PPSC

What is the purpose of the union() method for sets?

Question 7 of 40
★ FPSC ★ PPSC

In Python, how can you check if an element exists in a set?

Question 8 of 40
★ FPSC ★ PPSC

What method is used to remove an element from a set without raising an error if the element is not present?

Question 9 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_set = {1, 2, 3} print(my_set)

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following code: my_set = {1, 2, 3} my_set.add(4) print(my_set)

Question 11 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_set = {1, 2, 3, 4, 5} my_set.pop() print(my_set)

Question 12 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_set = {1, 2, 3} my_set.remove(2) print(my_set)

Question 13 of 40
★ FPSC ★ PPSC

Which method is used to find the intersection of two sets?

Question 14 of 40
★ FPSC ★ PPSC

What is the output of the following code: set1 = {1, 2, 3} set2 = {1, 2} print(set1.issuperset(set2))

Question 15 of 40
★ 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)

Question 16 of 40
★ 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])

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={3,4,5} >>> a.update([1,2,3]) >>> a

Question 18 of 40
★ FPSC ★ PPSC

What is the purpose of the clear() method for sets?

Question 19 of 40
★ 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)

Question 20 of 40
★ FPSC ★ PPSC

If a={5,6,7,8}, which of the following statements is false?

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> s={5,6} >>> s*3

Question 22 of 40
★ FPSC ★ PPSC

In Python, how can you check if two sets have no elements in common?

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? s={4>3, 0, 3-3} all(s) any(s)

Question 24 of 40
★ 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

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={5,6,7} >>> sum(a,5)

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x=set('abcde') y=set('xyzbd') x.difference_update(y) x y

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={1,2,3} >>> b=frozenset([3,4,5]) >>> a-b

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={1,2,3} >>> a.intersection_update({2,3,4,5}) >>> a

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? l=[1, 2, 4, 5, 2, 'xy', 4] set(l) l

Question 30 of 40
★ FPSC ★ PPSC

What is the purpose of the issuperset() method for sets?

Question 31 of 40
★ FPSC ★ PPSC

Is the following Python code valid? >>> a=frozenset([5,6,7]) >>> a >>> a.add(5)

Question 32 of 40
★ 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)

Question 33 of 40
★ FPSC ★ PPSC

Which of these about a set is not true?

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? a=set('abc') b=set('def') b.intersection_update(a) a b

Question 35 of 40
★ FPSC ★ PPSC

What is the purpose of the intersection() method for sets?

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={1,2,3} >>> b=a >>> b.remove(3) >>> a

Question 37 of 40
★ FPSC ★ PPSC

The . . . . . . . . function removes the first element of a set and the last element of a list.

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={4,5,6} >>> b={2,8,6} >>> a+b

Question 39 of 40
★ FPSC ★ PPSC

Which of the following lines of code will result in an error?

Question 40 of 40
★ FPSC ★ PPSC

Which of the following functions cannot be used on heterogeneous sets?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →