How to use sets and related methods of sets in python | Full Python Course in Hindi

hey Sushil KE IS VIDEO WHAT IS SET IN PYTHON ME FOLLOWING TOPICS KE BARE ME BATAYA GAYA HAI:

1. WHAT IS SET IN PYTHON?

2. HOW TO USE SET IN PYTHON?

3. WHY SET IS DIFFERENT THEN ARRAY?

4. PYTHON SET USE FOR UNION AND INTERSECTION?

5. SET METHODS USE TO SOLVE DUPLICATE PROBLEMS?

# Set

setvalue = {1,2,3,4,5,6}

# access
print('\n',10 in setvalue)

# add
setvalue.add(10)

# update
setvalue.update([11,22,33,44])

# Get the Length of a Set len()

# Remove Item
# setvalue.remove(101)

# discard()
setvalue.discard(101)

# pop
setvalue.pop()

# clear()
# setvalue.clear()

# del
# del setvalue

# Join Two Sets
secondset = {11,12,13,14}
setvalue.union(secondset)

# update
setvalue.update(secondset)

print('\n\nSet value: ',setvalue)

heySushil

Software Developer | Python | Data Science | Trainer | Motivation Speaker | Poetry | Animals Lover | Photographer |🧘🏻‍♂️Yoga | YouTube @heykyakaru

Leave a Reply