Python Tuple & List
RevivingIndia Meena bazar, Patna, IndiaWhat is Tuple? A tuple is a collection that is ordered and unchangeable. Tuples are written with round brackets. It is a collection of objects which ordered and immutable. Allow duplicate values. How to create Tuple? #Empty Tuple empty_tuple = () print (empty_tuple) #Single Element To write a tuple containing a single value you have to include a comma, even though there is only one value x= (50,) #mutiple element x= ("apple", “54.23", “23", "apple", “India") print (this tuple) READ OR ACCESS To access values in the tuple, use the square brackets. For multiple elements use slicing. X = (10,20,30) X X #Range of Indexes You can use positive and negative index both. How to update Tuple? Tuples are unchangeable, that you cannot change, add, or remove items once the tuple is created. tup1 = (12, 34.56) # Following action is not valid for tuples tup1 = 100 #throw Error How to…