Difference Between Tuple and List
Tuple vs List
Tuples and lists are two different but similar sequence types of the Python language.
Python
Python is a software language which helps one in working more quickly and increases the productivity of the program. It also helps in lowering the cost of maintenance. It is a programming language which helps in integrating the systems effectively, efficiently, and cost effectively.
Python is a language which can be used for free for domestic or commercial products. The reason is that it is OSI (Open Source License) approved. It runs on Mac OS X, Windows, Linux/Unix. Python has been ported to .NET virtual machines and Java.
Tuples and lists of Python are similar sequence types thus causing confusion among people learning the language, but they have some very distinct differences.
Tuples
The literal syntax of tuples is shown by parentheses.
Tuples are immutable. By “immutable,” it is meant that once they are created, they do not support any additional operations which might be added to the language and cannot be modified after they are created.
Tuples are heterogeneous. “Heterogeneous” means that generally tuples are a sequence type which have varied and different types, or the entries made have separate meanings.
A tuple is considered a coherent unit.
Tuples shows structure.
Lists
The literal syntax of lists is shown by square brackets.
Lists are mutable. By “mutable” it is meant that these objects are capable of supporting additional operations. So the list sequence is a type of sequence which supports operations when it is added to the language even after the creation.
They are homogeneous. By “homogeneous,” it means that these sequence types deal with the similar or same kinds of things. One has to deal individually with the items.
Lists show order.
Summary:
1.Tuples and lists are two similar sequences of the same programming language, Python. Tuples are immutable which means they cannot be modified once they are created; whereas, a list is a sequence which is mutable. It can be modified after it is created, and it supports additional operations too.
2.The literal syntax of tuples is shown by parentheses whereas the literal syntax of lists is shown by square brackets.
3.Tuples are heterogeneous while lists are homogeneous. One has to deal individually with the items.
4.Tuples show structure whereas lists show order.
- Difference Between Data Mining and Data Warehousing - October 21, 2012
- Difference Between 7-Keto DHEA and DHEA - October 20, 2012
- Difference Between Tamil and Malayalam - October 18, 2012
Search DifferenceBetween.net :
Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.
Doesn’t mention the very important fact that since tuples are immutable they can be hashed and used as keys in Python dictionaries and sets.