Skip to main content

Sets In Python — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Sets In Python — Part 2 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

The following Python code results in an error. s={2, 3, 4, [5, 6]}

Question 2 of 40
★ FPSC ★ PPSC

Which of the following is not the correct syntax for creating a set?

Question 3 of 40
★ FPSC ★ PPSC

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

Question 4 of 40
★ FPSC ★ PPSC

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

Question 5 of 40
★ FPSC ★ PPSC

In Python, how can you check if a set is a subset of another set?

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? s1={1, 2, 3} s2={4, 5, 6} s1.isdisjoint(s2) s2.isdisjoint(s1)

Question 7 of 40
★ FPSC ★ PPSC

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

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? s=set() type(s)

Question 9 of 40
★ FPSC ★ PPSC

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

Question 10 of 40
★ FPSC ★ PPSC

Is the following Python code valid? a={3,4,{7,5}} print(a[2][0])

Question 11 of 40
★ FPSC ★ PPSC

Input order is preserved in sets.

Question 12 of 40
★ FPSC ★ PPSC

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

Question 13 of 40
★ FPSC ★ PPSC

Write a list comprehension for number and its cube for: l=[1, 2, 3, 4, 5, 6, 7, 8, 9]

Question 14 of 40
★ FPSC ★ PPSC

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

Question 15 of 40
★ FPSC ★ PPSC

If we have two sets, s1 and s2, and we want to check if all the elements of s1 are present in s2 or not, we can use the function:

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Python function? {x for x in 'abc'} {x*3 for x in 'abc'}

Question 17 of 40
★ FPSC ★ PPSC

What is the syntax of the following Python code? >>> a=frozenset(set([5,6,7])) >>> a

Question 18 of 40
★ FPSC ★ PPSC

What method is used to find the elements that are present in either of the sets, but not in both sets?

Question 19 of 40
★ FPSC ★ PPSC

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

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code, if s1= {1, 2, 3}? s1.issubset(s1)

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? {a**2 for a in range(4)}

Question 22 of 40
★ FPSC ★ PPSC

The difference between the functions discard and remove is that:

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? s1={3, 4} s2={1, 2} s3=set() i=0 j=0 for i in s1: for j in s2: s3.add((i,j)) i+=1 j+=1 print(s3)

Question 24 of 40
★ FPSC ★ PPSC

Which of these about a frozenset is not true?

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={1,2,3} >>> {x*2 for x in a|{4,5}}

Question 26 of 40
★ FPSC ★ PPSC

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

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,8,10,11} >>> a^b

Question 28 of 40
★ FPSC ★ PPSC

The output of the following code is: class<'set'>. type({})

Question 29 of 40
★ FPSC ★ PPSC

Set members must not be hashable.

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? a = [5,5,6,7,7,7] b = set(a) def test(lst): if lst in b: return 1 else: return 0 for i in filter(test, a): print(i,end=" ")

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following code: set1 = {1, 2, 3} set2 = {3, 4, 5} print(set1.intersection(set2))

Question 32 of 40
★ FPSC ★ PPSC

Which of the following functions will return the symmetric difference between two sets, x and y?

Question 33 of 40
★ FPSC ★ PPSC

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

Question 34 of 40
★ FPSC ★ PPSC

In Python, how can you create an empty set?

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? s1={1, 2, 3} s2={3, 4, 5, 6} s1.difference(s2) s2.difference(s1)

Question 36 of 40
★ FPSC ★ PPSC

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

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? s={1, 2, 3} s.update(4) s

Question 38 of 40
★ FPSC ★ PPSC

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

Question 39 of 40
★ FPSC ★ PPSC

Which of the following statements is used to create an empty set?

Question 40 of 40
★ FPSC ★ PPSC

If a={5,6,7}, what happens when a.add(5) is executed?

✓ 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 →