14. Set
What are sets?
varset = {"Console","Python","data","Flare"}
print(varset){'data', 'Python', 'Console', 'Flare'}Properties of Sets:
1.Sets are Unordered :
varset = {"Console","Python","data","Flare"}
print(varset){'Python', 'data', 'Flare', 'Console'}Indexing and Slicing in Sets:
Sets are Mutable :
Sets do not allow duplicate values :
Functions used in sets:
Type of a set:
Set Methods:
Adding an item or a single element in a set: add()
Adding iterables elements individually : union() and update()
union():
update():
How to remove set items from set using methods : remove() , discard() , pop()
remove():
discard():
Difference between remove() and discard():
pop():
difference() and difference_update():
difference_update :
intersection() and intersection_update():
intersection_update():
symmetric_difference and symmetric_difference_update:
symmetric_difference:
symmetric_difference_update :
issubset:
issuperset:
isdisjoint() :
clear():
copy() :
set() Constructor :
How to create an Empty set:
Last updated