🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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))
  1. A.[3, 4] 5
  2. B.[1, 2, 5] 5
  3. C.[1, 2, 5] 7
  4. 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 →