Sets Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q21
Which method returns a copy of the set?
  • A clone()
  • B copy()
  • C duplicate()
  • D replicate()
Answer: Option B
Explanation: copy() returns a shallow copy of the set.
Q22
What is the output of: bool(set())?
  • A True
  • B False
  • C None
  • D Error
Answer: Option B
Explanation: An empty set evaluates to False in boolean context, while non-empty sets evaluate to True.
Q23
Which method adds multiple elements to a set?
  • A add_multiple()
  • B extend()
  • C update()
  • D insert_many()
Answer: Option C
Explanation: update() method adds elements from iterables (lists, tuples, other sets) to the current set.
Q24
What is the result of: 2 in {1, 2, 3}?
  • A True
  • B False
  • C 2
  • D Error
Answer: Option A
Explanation: The 'in' keyword checks for membership in sets and returns True if the element is found.
Q25
Which of these creates a set with elements 1, 2, 3?
  • A [1, 2, 3]
  • B (1, 2, 3)
  • C {1, 2, 3}
  • D <1, 2, 3>
Answer: Option C
Explanation: Both set([1, 2, 3]) and {1, 2, 3} create sets, but {1, 2, 3} is the preferred literal syntax.
Questions and Answers for Competitive Exams Various Entrance Test