Question 1 Sets Basics

Create a Set and Iterate Through Its Elements

Write a Python program to create a set containing multiple data types, iterate over the elements using a for loop, and display each item.

Solution Code Screenshot Click image to zoom
Set Create and Iterate Solution
Question 2 Sets Add & Remove

Add and Remove Elements from a Set

Write a Python program to demonstrate adding new items to a set using `add()` and `update()`, and removing items using `remove()`, `discard()`, and `pop()`.

Solution Code Screenshot Click image to zoom
Set Add and Remove Solution
Question 3 Sets Union

Find the Union of Two Sets

Write a Python program to find and display the union of two numeric sets using both the `union()` method and the pipe operator (`|`).

Solution Code Screenshot Click image to zoom
Set Union Solution
Question 4 Sets Intersection

Find Common Elements (Intersection) of Sets

Write a Python program to compute the intersection of two sets using the `intersection()` method and the `&` operator to display items common to both.

Solution Code Screenshot Click image to zoom
Set Intersection Solution
Question 5 Sets Set Difference

Find Set Difference (Elements in A but Not in B)

Write a Python program to calculate the set difference between two sets `A` and `B` using both the `difference()` method and the minus (`-`) operator.

Solution Code Screenshot Click image to zoom
Set Difference Solution
Question 6 Sets Symmetric Difference

Compute Symmetric Difference Between Two Sets

Write a Python program to find all elements that are in either of the two sets but not in both (symmetric difference) using the `symmetric_difference()` method and the `^` operator.

Solution Code Screenshot Click image to zoom
Set Symmetric Difference Solution
Question 7 Sets Deduplication

Remove Duplicate Values from a List Using a Set

Write a Python program to take a list with repeated values, convert it to a set to filter out duplicates, and convert it back into a unique list.

Solution Code Screenshot Click image to zoom
Remove Duplicates Using Set Solution
Question 8 Sets Subset / Superset

Check if a Set is a Subset or Superset of Another

Write a Python program to test whether set `A` is a subset of set `B` using `issubset()`, and whether set `B` is a superset of set `A` using `issuperset()`.

Solution Code Screenshot Click image to zoom
Set Subset Superset Solution
Question 9 Sets Min / Max

Find Maximum and Minimum Elements in a Set

Write a Python program to find both the largest and smallest values in a set of integers without converting it into a list.

Solution Code Screenshot Click image to zoom
Set Max Min Solution
Question 10 Sets Vowel Intersection

Find Unique Vowels Present in a String Using a Set

Write a Python program that accepts a sentence from the user and uses set intersection with `{'a', 'e', 'i', 'o', 'u'}` to identify and count all unique vowels present.

Solution Code Screenshot Click image to zoom
Set Count Vowels Solution
Question copied to clipboard!