1. Home
  2. Data Science
  3. Python
  4. What is the result of {1, 2, 3} | {3, 4, 5} in Python?

Added 4 May 2024

What is the result of {1, 2, 3} | {3, 4, 5} in Python?

  1. {1, 2, 3, 4, 5} Correct answer
  2. {1, 2}
  3. {3}
  4. Error

Correct answer

A. {1, 2, 3, 4, 5}

16 views

MCQSEXAM

Explanation

The | operator performs a union of two sets, resulting in a set containing all unique elements from both sets.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs