1. Write a python program to generate an empty set and non-empty set as non_empty_set which provided in the following
The output is:
non_empty_set = set(['Python', 'free', 'Exercises', 'Tutorials'])
Expected Answer:
The empty set: set()
The non empty set: {'Python', 'free', 'Exercises', 'Tutorials'}
2. Write a python program to iterate one set_a which provided in the following
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials', 'Sets', 'Library'])
Expected Answer:
Free
Python
Sets
Library
Exercises
Tutorials
3. Write a python program to add one item into set_a which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials', 'Sets', 'Library'])
add one item: 'Answer'
Expected Answer:
After adding new item 'Answer' is: {'Free', 'Python', 'Sets', 'Library', 'Exercises', 'Tutorials', 'Answer'}
4. Write a python program to add more than one item into set_a which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials', 'Sets', 'Library'])
add two items: 'Answer' and 'List'
Expected Answer:
After adding new items 'Answer' and 'List' is: {'Free', 'Python', 'List', 'Sets', 'Library',
'Exercises', 'Tutorials', 'Answer'}
5. Write a python program to remove any one or two items from set_a which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials', 'Sets', 'Library'])
Expected Answer:
After removing first item: {'Python', 'Sets', 'Library', 'Exercises', 'Tutorials'}
After removing second item: {'Sets', 'Library', 'Exercises', 'Tutorials'}
6. Write a python program to remove a selected item from set_a which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials', 'Sets', 'Library'])
Remove item: 'Exercises'
Expected Answer:
After removing item 'Exercises': {'Free', 'Python', 'Sets', 'Library', 'Tutorials'}
7. Write a python program to generate an intersection of set_a and set_b which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials'])
set_b = set(['Tutorials', 'Sets', 'Library', 'List'])
Expected Answer:
The intercept value is: {'Tutorials'}
8. Write a python program to generate a symmetric difference between set_a and set_b which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials'])
set_b = set(['Tutorials', 'Free', 'Library'])
Expected Answer:
The symmetric difference of values are: {'Python', 'Library', 'Exercises'}
9. Write a python program to generate an union of set_a and set_b which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials'])
set_b = set(['Tutorials', 'Free', 'Library'])
Expected Answer:
The union of set values are: {'Free', 'Library', 'Python', 'Exercises', 'Tutorials'}
10. Write a python program to generate set difference in set_a from set_b which provided in the following output.
The output is:
set_a = set(['Python', 'Free', 'Exercises', 'Tutorials'])
set_b = set(['Tutorials', 'Free', 'Library'])
Expected Answer:
The set difference of values are: {'Python', 'Exercises'}
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)