← Back to the lesson: Sets
Set Operations
The exercise
Given two sets:
set_a = {1, 2, 3, 4}
set_b = {3, 4, 5, 6}
Find and print:
1. Common elements (intersection) using &
2. All elements combined (union) using |
Starter code
set_a = {1, 2, 3, 4}
set_b = {3, 4, 5, 6}
# Find intersection / Найдите пересечение
intersection =
# Find union / Найдите объединение
union =
# Print both / Выведите оба
Write the code in the browser and run it — no installation needed.