Set Programming Exercises
1. Create a Set from a String Create a set named vowels using the set() function from the
string "education".
2. Add a Single Element Add the number 100 to the set points = {10, 20, 30, 40,
50}.
3. Add Multiple Elements Add the numbers 60, 70, 80 to the points set using a single
method.
4. Remove a Specific Element Delete the character 'z' from the set chars = {'x', 'y',
'z', 'w'}.
5. Set Union Find the union of set_a = {1, 2, 3} and set_b = {3, 4, 5} and store it
in set_c.
6. Set Intersection Find the common elements between set_x = {'apple', 'banana',
'cherry'} and set_y = {'google', 'microsoft', 'apple'}.
7. Set Difference Create a new set that contains elements present in set_p = {10, 20,
30} but NOT in set_q = {20, 40}.
8. Copying a Set Create a shallow copy of a set named original_set = {5, 10, 15}
into a new variable called backup_set.
9. Membership Testing Check if the value 50 exists in the set data = {10, 30, 50, 70}
and print the result.
10. Clear a Set Remove all elements from the set temp_data = {1, 2, 3} without deleting
the set variable itself.