Sets

AΒ 
set
Β 
isΒ 
aΒ 
collectionΒ 
thatΒ 
isΒ 
bothΒ 
unorderedΒ 
andΒ 
unindexed
.Β 
SetsΒ 
areΒ 
definedΒ 
withΒ 
curlyΒ 
{}
Β 
brackets.Β 
TheyΒ 
cannotΒ 
haveΒ 
twoΒ 
itemsΒ 
withΒ 
theΒ 
sameΒ 
value.Β 
TheΒ 
valueΒ 
isΒ 
storedΒ 
onlyΒ 
once
.Β 
ItΒ 
isΒ 
aΒ 
veryΒ 
usefulΒ 
toolΒ 
toΒ 
removeΒ 
repeatedΒ 
values.
set_name={values}
set1 = {"apple", "banana", "cherry"}
set2 = {1, 5, 7, 9, 3}
set3 = {True, False, False}

print(set1)
print(set2)
print(set3)

Conversion of List/Tuple to Set

TheΒ 
set()
Β 
functionΒ 
isΒ 
usedΒ 
toΒ 
convertΒ 
aΒ 
list/tupleΒ 
toΒ 
aΒ 
set.Β 
ItΒ 
removesΒ 
anyΒ 
repeatedΒ 
elementsΒ 
ofΒ 
theΒ 
list/tupleΒ 
andΒ 
storesΒ 
themΒ 
onlyΒ 
once.
list_to_set = set(list)
tuple_to_set = set(tuple)
list_to_set = set([1,2,1,4,2])
tuple_to_set = set(('a', 'b', 'c'))
print(list_to_set)
print(tuple_to_set)