← All Exercises
Python Set Operations
basicpython
Background
Set operations are fundamental for comparing collections, finding common elements, and deduplication in data processing.
Problem
Write a function that takes two lists and returns a dictionary with their union, intersection, and differences as sets.
Input
Two lists of comparable elements.
Output
A dictionary with union, intersection, and both differences.
Sample tests
Sample 1
Input: [1,2,3], [2,3,4]
Expected: {union:{1,2,3,4}, inter:{2,3}, diff1:{1}, diff2:{4}}Your solution
Learning objective
Learn set operations using Python operator syntax and understand their efficiency.