PYTHON-SET Author: CloudVikas Published Date: 9 December 2020 Welcome to your PYTHON-SET What is the difference between add() and update() functions in set? We can use add() to add individual item to the Set,where as we can use update() function to add multiple items to Set. add() function can take only one argument where as update() function can take any number of arguments but all arguments should be iterable objects. add() function can take many arguments where as update() function can take one argument How will you use remove function in Python? It removes specified element from the set. If the specified element not present in the Set then we will get KeyError. If the specified element not present in the Set then we will not get any Error s={40,10,30,20} s.remove(60) print(s) ---error How will you use discard function in Python? It removes the specified element from the set. If the specified element not present in the set then we won't get any error. s={10,20,40} s.discard(10) print(s) ===>{20, 40} s.discard(50) print(s) ==>{20, 40} If the specified element not present in the set then we get an error. Write a program to eliminate duplicates present in the list?Add description here! 1. l=eval(input("Enter List of values: ")) 2. s=set(l) 3. print(s) 1. l=eval(input("Enter List of values: ")) 2. l1=[] 3. for x in l: 4. if x not in l1: 5. l1.append(x) 6. print(l1) A set contains names which begin either with A or with B. write a program to separate out the names into two sets, one containing names beginning with A and another containing names beginning with B.# Split given set into two sets lst = {'Adi', 'Amit', 'Amar', 'Babu', 'cat', 'baba', 'baat'} x = set() y = set() for item in lst: if item.startswith('A'): x.add(item) elif item.startswith('B'): y.add(item) print(x) print(y)TrueFalse What is the difference between the two set functions— discard() and remove()remove() raises an exception when the element which we are trying to remove is not present in the set, whereas, discard() doesn’.t.discard() raises an exception when the element which we are trying to remove is not present in the set, whereas, remove() doesn’.t. How will you remove all duplicate elements present in a strings = 'vikas's = ''.join(sorted(set(s), key = s.index))s = ''.join(sorted(set(s), key = s.index((2)) How will you remove all duplicate elements present in a list?lst = list(sorted(set(lst), key = lst.index))lst = list(sorted(set(lst), key = lst.index+1)) Time is Up! Time's up Author: CloudVikas