#File: ChapterLists/setmodule.py """Given two lists, computes the union and intersection of the two lists works with any kind of lists no sorting needed L1 = [2, 4, 6] L2 = [4, 8, 5, 5, 5] S1= {2, 4, 6} S2 = {8, 4, 5} intersection= {4} S1= {2, 4, 6} S2 = {8, 4, 5} union= {2, 4, 5, 6, 8} S1= {2, 4, 6} S2 = {8, 4, 5} difference= {2, 6} turing {'t', 'r', 'g', 'u', 'i', 'n'} """ def main(): L1 = [2,4,6] L2 = [4,8,5,5,5] print("L1 =", L1, "L2=", L2) # conversion lists to sets S1 = set(L1) #{2, 4, 6} S2 = set(L2) #{4, 8, 5} - removes duplicates and sorts #apply set operations print("S1=", S1, "S2=", S2, "intersection= ",S1.intersection(S2)) print("S1=", S1, "S2=", S2, "union= ",S1.union(S2)) print("S1=", S1, "S2=", S2, "difference= ",S1.difference(S2)) w ="turing" S = set(w) print(w, S) main()