Image

Programs - Python - Set and Frozen Set

Program:

myset={1,2,3,"sanjay",5.66,"rahul","ayush"}
print(myset)
myset.add(60)
print(myset)

#myset.discard(3)
myset.remove(3)
print(myset)

newset={1,2,3,"sanjay",5.66,"rahul","ayush"}
print(type(newset))

fs=frozenset(newset)
print(type(fs))

Output:

{1, 2, 3, sanjay, 5.66, ayush, rahul}
{1, 2, 3, sanjay, 5.66, ayush, rahul, 60}
{1, 2, sanjay, 5.66, ayush, rahul, 60}