44.Example Programs using set
Write a program to do basic set operations na=int(input('Enter number of elements of the set A ..')) A=set() print("Enter the elements of set A...") for i in range(na): x=int(input()) A.add(x) nb=int(input('Enter number of elements of the set B ..')) B=set() print("Enter the elements of set B...") for i in range(nb): x=int(input()) B.add(x) print("set operations..") print("union") print(A|B) print("Intersection") print(A&B) print("Difference A-B and B-A") print(A-B) print(B-A) print("symmetric Difference") print(A^B) The simple way to remove duplicate elements from a list is to convert into a set and then convert back to list lst=[] n=int(input("enter how many numbers..")) print("Enter elements...") for i in range(n): x=int(input()) lst.append(x) nlst=list(set(lst)) print("new list after removing duplicates") print(nlst) This program will compl