Practice With Interview Questions: ================================== # WAP TO ADD ELEMENTS TO A TUPLE. """ 1) create the tuple 2) tuple ==> list 3) adding of elements into list 4) resultant list ==> tuple 5) print the tuple """ # create an empty tuple td = tuple() print("The Tuple before the adding elements = ",td) # convert the tuple to list ld = list(td) # adding elements for i in range(10,100,15): ld.append(i) print("The Resultant list = ",ld) # resultant list ==> tuple td = tuple(ld) # print the tuple print("The Tuple After adding elements is = ",td) ========================================================= # WAP TO GET 4TH ELEMENT FROM THE LAST ELEMENT OF THE TUPLE. """ [1,2,3,4,5,6,7,8,9,10] OUTPUT: 7 """ td = eval(input("Enter a tuple data:")) # print("The 4th Element of tuple is = ",td[3]) print("The 4th Element of the tuple from last element is = ",td[-4]) ============================================================ # WAP TO FIND REPETED ITEMS IN A TUPLE. # WAP TO FIND THE REPEATED ITEMS OF TUPLE. """ (1,2,3,4,1,2,3,4,1,1,10) (1,2,3,4) """ # create the tuple td = eval(input("Enter a tuple:")) ld = [] for i in td: if td.count(i) > 1: ld.append(i) else: continue for i in ld: while ld.count(i) > 1: ld.remove(i) print("The Tuple with repeated elements:",tuple(ld)) ======================================== # WAP TO REVERSE THE TUPLE. # reverse of the tuple td = (1,3,5,7,9) rev_tuple = tuple(reversed(td)) print(rev_tuple)