Python Lab Manual Answers (22616) MSBTE
Practical 8: Write Python program to perform following operations on
Set: Create Set, Access Set elements, Update Set, Delete Set
X. Practical related Questions
1. Describe the various set operations
Ans=>1) Set is collection of objects set are unordered. we can't access elements of sets by index. We Can perform different operations on sets below we have mention them
2) Intersection: This operation returns elements of sets which presents in both sets.
2) Difference : this operation returns set of all elements in first set that are not in second set
3) Union : This operation returns set of all elements that present in both sets but avoid duplicates
2. Describe the various methods of set
Ans=> 1) add() : Add An element to the set.
2) copy() : Return copy of set.
3) discard() : Remove specified element from set.
4) issubset() : Check that whether given set is subset of second set.
5) pop () : Removes element from the set
.
XI. Exercise
1. Write a Python program to create a set, add member(s) in a set and remove one
item from set.
Ans=>
2. Write a Python program to perform following operations on set: intersection of sets, union of sets, set difference, symmetric difference, clear a set.
Ans=>
3. Write a Python program to find maximum and the minimum value in a set.
Ans=>
4. Write a Python program to find the length of a set.
Ans=>
Hello Guys if you find it helpful then dont forget to share with your friends...
.
.
.
.
.
keep Growing❤
0 Comments