Posts

Showing posts from March, 2022
def switch (): a = [] b = [] n = int ( input ( "Number of elements in array:" )) for i in range ( 0 , n): l = int ( input ()) a.append(l) print ( "Press 1 for Add \n Press 2 for remove \n Press 3 for union" ) option = int ( input ( "Enter your option: " )) if option == 1 : z = int ( input ( "number which you want to add in set:" )) a.append(z) print ( "updated set : " , a) elif option == 2 : z = int ( input ( "number which you want to add in set:" )) a.remove(z) print ( "updated set : " , a) elif option == 3 : r = int ( input ( "enter second set for union :" )) for i in range ( 0 , r): l = int ( input ()) b.append(l) a.extend(b) print ( "Union of set a and b is" , a) switch() Set operations class setExample: set1=set() set2=set(["Kum...