Introduction
This is another article which is focusing the content to write about one of the collection data type available in Python programming language. In this article, the focus is in list as one of the collection data type available in Python programming language. Beside list, there is a collection data type with the name of tuple. For more information about all data types available in Python programming language, just check this link. It will direct to an article with the title of ‘Data Type in Python’.
Tuple Characteristics
In case of tuple as one of collection data type available in Python programming language, the following is the characteristics of it :
-
Number of data.
As all of the collection data types available in Python programming language, it can store or it contains multiple data.
Since it is a collection data type, it is available for storing multiple data as in the following example : (1,2,3,4,5,6).
-
Data types.
Another characteristics for tuple, also like list, it can store or can contain multiple data with multiple data types.
For a short explanation, it can have any type of data with any data types. In Python programming language, there are many data types available. As a reference, just access this link which is an article with the title of ‘Data Type in Python’. So, tuple can have many data with various data types as the example of : (True, ‘Steve’,”France”,89,73.1)
-
Mutability.
Unlike list which is a collection data type where it have the ability to change along the way, tuple is not like that. After defining tuple, the data available in it cannot change after the initialization. Adding element is perfectly fine and it is doable with tuple, but changing the existing data is not an option.
-
Initialization or Definition Format.
In terms of tuple, the initialization or the definition for tuple is different with list. If list is using square bracket as ‘[]’, tuple is using rounded bracket as ‘()’. For an example, the initialization or the definition for tuple is already exist above.
-
Data Duplication
As list, tuple is also allowing duplicate data. For an example as follows : (1, 1, True, False, True, 0, ‘Mike’, ‘Mike’, 3.45, 30, 40, ‘Danny’, True, ‘Denmark’, 32.04, 30, 40, 32.04, ‘Mike’)
One thought on “Tuple in Python”