The program is written in Python and performs the following steps:
In Python, tuples are immutable, which means that once a tuple is created, its elements cannot be changed. However, it is possible to create a new tuple by concatenating existing tuples. In this program, the original tuple t is concatenated with another tuple to create a new tuple with more items. To add items to a tuple, it must be first converted to a list, and then the list can be modified. The final step converts the list back to a tuple.
#create a tuple t = (10,40,50,70,90) print(t) t = t + (20,) print(t) #converting the tuple to list l = list(t) #use different ways to add items in list l.append(30) t = tuple(l) print(t)
(10, 40, 50, 70, 90) (10, 40, 50, 70, 90, 20) (10, 40, 50, 70, 90, 20, 30)
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions