What is the result of {1, 2, 3} | {3, 4, 5} in Python?
-
A
{1, 2, 3, 4, 5}
Correct answer
-
B
{1, 2}
-
C
{3}
-
D
Error
Correct answer
A. {1, 2, 3, 4, 5}
16 views
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