← Quiz: Sets, Relations and Functions: all 10 questions
Quiz: Sets, Relations and Functions · Question 7 of 10
What does this print? (code)
What does this print?
A = {1, 2, 3, 4}
B = {3, 4, 5}
print(sorted(A ^ B), len(A | B))
- A.[3, 4] 5
- B.[1, 2, 5] 5
- C.[1, 2, 5] 7
- D.[1, 2] 4
Answer & explanation
Correct answer: [1, 2, 5] 5
The symmetric difference keeps elements in exactly one set; the union has 5 elements.
Can you get the rest right without peeking?
Take the timed Quiz: Sets, Relations and Functions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →