PYnative

Python Programming

  • Learn Python
  • Exercises
  • Quizzes
  • Code Editor
  • Tricks
Home » Python » Quizzes » Python Set Quiz

Python Set Quiz

Updated on: August 24, 2022 | 16 Comments

This Python Set quiz provides Multiple Choice Questions(MCQ) to get familiar with Python Set operations. This online quiz will help you to improve your understanding of the Python set.

Also, See: Python Set Exercise.

  • The quiz contains 16 Questions. Solve 11 correct to pass the test.
  • You will have to read all the given answers and click over the correct answer.
  • Read guide on Sets In Python to solve this quiz.

1. What is the output of the following

set1 = {10, 20, 30, 40, 50}
set2 = {60, 70, 10, 30, 40, 80, 20, 50}

print(set1.issubset(set2))
print(set2.issuperset(set1))
 
 

2. What is the output of the following

sampleSet = {"Yellow", "Orange", "Black"}
sampleSet.discard("Blue")
print(sampleSet)
 
 

3. Select all which is true for Python set

 
 

4. What is the output of the following union operation

set1 = {10, 20, 30, 40}
set2 = {50, 20, "10", 60}

set3 = set1.union(set2)
print(set3)
 
 
 
 

5. The symmetric_difference() method returns a set that contains all items from both sets, but not the items that are present in both sets.

 
 

6. What is the output of the following

sampleSet = {"Yellow", "Orange", "Black"}
sampleSet.add("Blue")
sampleSet.add("Orange")
print(sampleSet)
 
 

7. The isdisjoint() method returns True if none of the items are present in both sets, otherwise, it returns False.

 
 

8. What is the output of the following code

aSet = {1, 'PYnative', ('abc', 'xyz'), True}
print(aSet)
 
 
 

9. What is the output of the following set operation

set1 = {"Yellow", "Orange", "Black"}
set2 = {"Orange", "Blue", "Pink"}

set3 = set2.difference(set1)
print(set3)
 
 
 

10. What is the output of the following set operation

sampleSet = {"Yellow", "Orange", "Black"}
sampleSet.update(["Blue", "Green", "Red"])
print(sampleSet)
 
 
 

11. What is the output of the following set operation.

set1 = {"Yellow", "Orange", "Black"}
set2 = {"Orange", "Blue", "Pink"}

set1.difference_update(set2)
print(set1)
 
 

12. What is the output of the following code

sampleSet = {"Yellow", "Orange", "Black"}
print(sampleSet[1])
 
 
 

13. The union() method returns a new set with all items from both sets by removing duplicates

 
 

14. Select all the correct options to remove “Orange” from the set.

sampleSet = {"Yellow", "Orange", "Black"}
 
 
 

15. Select all the correct ways to copy two sets

 
 

16. What is the output of the following code

aSet = {1, 'PYnative', ['abc', 'xyz'], True}
print(aSet)
 
 
 

Loading ... Loading …

Loading

Filed Under: Python, Python Basics, Python Quizzes

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

Founder of PYnative.com I am a Python developer and I love to write articles to help developers. Follow me on Twitter. All the best for your future Python endeavors!

Related Tutorial Topics:

Python Python Basics Python Quizzes

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 10 questions
  • Each Quiz contains 12-15 MCQ
Exercises
Quizzes

Posted In

Python Python Basics Python Quizzes
TweetF  sharein  shareP  Pin

  Python Quizzes

  • Python Quizzes Home
  • Basic Quiz For Beginners
  • Variables and Data Types Quiz
  • Operators and Expression Quiz
  • Input and Output Quiz
  • Functions Quiz
  • if else and loops Quiz
  • Numbers Quiz
  • String Quiz
  • List Quiz
  • Set Quiz
  • Dictionary Quiz
  • Tuple Quiz
  • File Handling Quiz
  • Random Data Generation Quiz

All Python Topics

Python Basics Python Exercises Python Quizzes Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our Terms Of Use, Cookie Policy, and Privacy Policy.

Copyright © 2018–2023 pynative.com