Posts

Showing posts with the label tuple

Topic 13: Tuple

Image
Tuple in Python? In Python, t uples are one of the most important data types used to store multiple items in a single variable. They are similar to lists, but tuples are immutable   (अपरिवर्तनीय) ,  meaning their elements cannot be changed once assigned. Tuples are often used when you want to store a fixed collection of items that should not be modified during program execution. What is a tuple in Python? A tuple is an ordered , immutable , and heterogeneous  ( भिन्न प्रकार)   collection of elements. You can store different data types such as integers, strings, floats, and even other tuples inside a tuple. Syntax: tuple_name = (element1, element2, element3, ...) Example: my_tuple = (10, 20, 30, "Python", 3.14) print(my_tuple) Output: (10, 20, 30, 'Python', 3.14) Characteristics of Tuples Feature Description Ordered Elements have a defined order and can be accessed by index. Immutable Once created, elements cannot be changed or removed...