''' Problem Statement: To create ADT that implement the "set" concept. a. Add (newElement) -Place a value into the set b. Remove (element) Remove the value c. Contains (element) Return true if element is in collection d. Size () Return number of values in collection Iterator () Return an iterator used to loop over collection e. Intersection of two sets f. Union of two sets g. Difference between two sets h. Subset Code from Data Structures and Algorithms (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/DataStructuresAndAlgorithms/ ''' # BEGINNING OF CODE setOne=[] setTwo=[] def addVal(Set): val = int(input("Value to add:\t")) Set.append(val) print(f"Set is:\t{Set}") def delVal(Set): val = int(input("Value to remove:\t")) if(val not in Set): print(f"{val} is not present in the set.") else: Set.remove(val) print(f"Set is:\t{Set}") def searchVal(Set): val = int(input("Value to search:\t")) if(val in Set): print(f"{val} is present in the set.") else: print(f"{val} is not present in the set.") def size(Set): p = iter(Set) for i in p: print(i) print("Size of set is:\t{len(Set)}") def intersection(): intersectionSet = [] for i in setOne: if i in setTwo: intersectionSet.append(i) print(f"Intersection set is {intersectionSet}") def union(): unionSet = [] for i in setOne: unionSet.append(i) for j in setTwo: if j not in setOne: unionSet.append(j) print("Union of set one and set two is:\t{union}") def difference(): differenceSet = [] for i in setOne: if i not in setTwo: differenceSet.append(i) print("Difference of set one and set two is:\t{differenceSet}") def subsetCheck(a,b): for i in b: if i not in a: return False return True def subset(): if subsetCheck(setOne,setTwo): print("Set two is a subset of set one.") else: print("Set two is not a subset of set one.") def menu(): while (True): print("--- MAIN MENU ---") print("1. Add value to set") print("2. Remove value from set") print("3. Search value in set") print("4. Show size of set") optn = int(input("Choose an option (1-):\t")) if (optn == 1): setSel = int(input("Which set to operate on?\n1. Set one\n2. Set two\nSet 1/2:\t")) if (setSel == 1): addVal(setOne) elif (setSel == 2): addVal(setTwo) else: print("Please choose a valid option.") elif (optn == 2): setSel = int(input("Which set to operate on?\n1. Set one\n2. Set two\nSet 1/2:\t")) if (setSel == 1): delVal(setOne) elif (setSel == 2): delVal(setTwo) else: print("Please choose a valid option.") elif (optn == 3): setSel = int(input("Which set to operate on?\n1. Set one\n2. Set two\nSet 1/2:\t")) if (setSel == 1): searchVal(setOne) elif (setSel == 2): searchVal(setTwo) else: print("Please choose a valid option.") ## PENDING menu() # END OF CODE