Python Tuples
Tuple is a built-in data structure in Python used to store a collection of objects. A tuple is similar to a Python list in terms of indexing, nested objects, and repetition. The main difference between both is that the tuples in Python are immutable, where as Python list which is mutable. How to create a tuple: my_tpl = (205, 16.25, 'Python', [20, 40, 60]) print(my_tpl) Some more examples in tuples: Example1 # Creating an empty tuple empty_tpl = () print("Empty tuple: ", empty_tpl) # Creating a tuple having integers int_tpl = (13, 56, 27, 18, 11, 23) print("Tuple with integers: ", int_tpl) # Creating a tuple having objects of different data types mix_tpl = (6, "Python", 17.43) print("Tuple with different data types: ", mix_tpl) # Creating a nested tuple nstd_tpl = ("Python", {4: 5, 6: 2, 8: 2}, (5, 3, 15, 6)) print("A nested tuple: ", nstd_tpl) Exa...