Sets in python: 18 MCQs
All 18 multiple-choice questions from this kit, free and with no sign-up.
Warm-up · 8 questions
Q1. What is the correct way to create an empty set in Python?
BeginnerAnswers and explanations are in the Veda app.
Q2. Which of the following is a property of a Python set?
BeginnerAnswers and explanations are in the Veda app.
Q3. Which method adds an element to a set?
BeginnerAnswers and explanations are in the Veda app.
Q4. What is the output of `len({1, 2, 3, 2, 1})`?
BeginnerAnswers and explanations are in the Veda app.
Q5. A set can contain duplicate elements.
BeginnerAnswers and explanations are in the Veda app.
Q6. You can access elements of a set using an index like `my_set[0]`.
BeginnerAnswers and explanations are in the Veda app.
Q7. The `clear()` method removes all elements from a set.
BeginnerAnswers and explanations are in the Veda app.
Q8. A set can contain both integers and strings.
BeginnerAnswers and explanations are in the Veda app.
Building up · 9 questions
Q9. What will be the output of `{1, 2, 3} | {2, 3, 4}`?
IntermediateAnswers and explanations are in the Veda app.
Q10. What does `{1, 2, 3} - {2, 3, 4}` return?
IntermediateAnswers and explanations are in the Veda app.
Q11. Which of the following cannot be an element of a set?
IntermediateAnswers and explanations are in the Veda app.
Q12. Which operator checks if a set is a subset of another?
IntermediateAnswers and explanations are in the Veda app.
Q13. What does `{1, 2, 3} & {2, 3, 4}` return?
IntermediateAnswers and explanations are in the Veda app.
Q14. Which method removes an element from a set and raises an error if not found?
IntermediateAnswers and explanations are in the Veda app.
Q15. What is the output of `{x**2 for x in range(3)}`?
IntermediateAnswers and explanations are in the Veda app.
Q16. What does `{1, 2}.issuperset({1})` return?
IntermediateAnswers and explanations are in the Veda app.
Q17. The `^` operator performs symmetric difference on sets.
IntermediateAnswers and explanations are in the Veda app.
Topper level · 1 questions
Q18. Which of the following is true about frozenset?
AdvancedAnswers and explanations are in the Veda app.
Your notes can be a kit like these
Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free to start, in more than 40 languages.
- Chapter notes
- Flashcards
- Practice MCQs
- Scored tests
- Paper Solver
Get Veda free See what students get
Free to start · Android app and web · More than 40 languages