Showing 10 of
25 questions
Questions per page:
5
10
20
50
11. Which operator represents symmetric difference?
Answer: Option
D
Hints: The caret (^) operator performs symmetric difference between two sets.
Show
Answer
Hide
Answer
Report
12. What is the result of len({1, 1, 2, 2, 3})?
Answer: Option
B
Hints: Sets remove duplicates, so {1, 1, 2, 2, 3} becomes {1, 2, 3} with length 3.
Show
Answer
Hide
Answer
Report
13. Which method removes a specific element from a set and raises error if not found?
discard()
remove()
pop()
delete()
Answer: Option
B
Hints: remove() raises KeyError if element is not found, while discard() does not raise an error.
Show
Answer
Hide
Answer
Report
14. What is the output of: {1, 2, 3} | {3, 4, 5}?
{1, 2, 3, 4, 5}
{3}
{1, 2, 4, 5}
{1, 2, 3}
Answer: Option
A
Hints: The | operator performs union operation, combining all unique elements from both sets.
Show
Answer
Hide
Answer
Report
15. Which method checks if a set is a subset of another?
subset()
contains()
issubset()
partof()
Answer: Option
C
Hints: issubset() checks if all elements of one set are present in another set.
Show
Answer
Hide
Answer
Report
16. What is the result of: {1, 2}.issuperset({1})?
Answer: Option
A
Hints: issuperset() returns True if the set contains all elements of the specified set.
Show
Answer
Hide
Answer
Report
17. Which method removes all elements from a set?
delete()
remove_all()
clear()
empty()
Answer: Option
C
Hints: clear() removes all elements from the set, making it empty.
Show
Answer
Hide
Answer
Report
18. What is the output of: {1, 2} - {2, 3}?
Answer: Option
A
Hints: The - operator returns elements that are in the first set but not in the second set.
Show
Answer
Hide
Answer
Report
19. Which of these data types can be elements of a set?
Lists
Dictionaries
Other sets
Tuples
Answer: Option
D
Hints: Sets can contain only hashable (immutable) types. Lists are mutable and cannot be set elements.
Show
Answer
Hide
Answer
Report
20. What is the result of: {1, 2} ^ {2, 3}?
Answer: Option
A
Hints: Symmetric difference returns elements that are in either set but not in both.
Show
Answer
Hide
Answer
Report