Difference Between Tuple and List
Syntax Difference
The literal syntax of tuples is shown by parentheses {} whereas the literal syntax of lists is shown by square brackets [] .
Mutable Vs. Immutable
The key difference is that tuples are immutable. This means that you cannot change the values in a tuple once you have created it. This is a good feature to have in some data structures where you intend to not make any changes to certain parts. As a list is mutable, it can't be used as a key in a dictionary because dictionaries can use any immutable object as a key. Thus, tuples can be used as dictionary keys if needed. If you try to modify a tuple in a permitted way it becomes two Tuples: the original, which remains fo every scope other than yours, and your modified copy for your scope.
List exampleReturn: ['red', 'yellow', 'green']
Tuple exampleoutput
Reused Vs. Copied
Tuples do not need to be copied: Running tuple(some_tuple) returns immediately itself. Since tuples are immutable, they do not have to be copied:
Return:true
In contrast, list(some_list) requires all the data to be copied to a new list:
Return:false
Size Comparison
Tuples operation has smaller size than that of list, which makes it a bit faster but not that much to mention about until you have a huge number of elements.
exampleHomogeneous Vs Heterogeneous
There's a strong culture of tuples being for heterogeneous collections, similar to what you'd use structs for in C, and lists being for homogeneous collections, similar to what you'd use arrays for. In other words, different data can be stored in single tuple while same type of data is stored in lists.
Other Differnces:
- Lists are for variable length , tuples are for fixed length .
- Tuples show structure whereas lists show order .
- Tuples have O(N) append, insert, and delete performance whereas Lists have O(1) append, insert and delete performance.
Looking for a Python job ?
There are lot of opportunities from many reputed companies in the world. Chances are you will need to prove that you know how to work with .Net Programming Language. These Python Interview Questions have been designed especially to get you acquainted with the nature of questions you may encounter during your interview for the subject of .Net Programming. Here's a comprehensive list of .Net Interview Questions, along with some of the best answers. These sample questions are framed by our experts team who trains for .Net training to give you an idea of type of questions which may be asked in interview. Go to... Python Interview QuestionsPython tuple
A Tuple is a collection of Python objects separated by commas which is ordered and unchangeable. Python tuple is similar to List except that the objects in tuple are immutable which means we cannot change the elements of a tuple once assigned.Python List

- Python Interview Questions (Part 2)
- Python Interview Questions (Part 3)
- What is python used for?
- Is Python interpreted, or compiled, or both?
- Explain how python is interpreted
- How do I install pip on Windows?
- How do you protect Python source code?
- What are the disadvantages of the Python?
- How would you achieve web scraping in Python?
- How to Python Script executable on Unix
- What is the difference between .py and .pyc files?
- What is __init__.py used for in Python?
- What does __name__=='__main__' in Python mean?
- What is docstring in Python?
- What is the difference between runtime and compile time?
- How to use *args and **kwargs in Python
- Purpose of "/" and "//" operator in python?
- What is the purpose pass statement in python?
- Why isn't there a switch or case statement in Python?
- How does the ternary operator work in Python?
- What is the purpose of "self" in Python
- How do you debug a program in Python?
- What are literals in python?
- What is Python's parameter passing mechanism?
- What is the process of compilation and Loading in python?
- Global and Local Variables in Python
- Is there a tool to help find bugs or perform static analysis?
- What does the 'yield' keyword do in Python?
- Comparison Operators != is not equal to in Python
- What is the difference between 'is' and '==' in python
- What is the difference between = and == in Python?
- How are the functions help() and dir() different?
- What is the python keyword "with" used for?
- Is all the memory freed when Python exits?
- Difference between Mutable and Immutable in Python
- Explain split() methods of "re" module in Python
- Accessor and Mutator methods in Python
- How to Implement an 'enum' in Python
- Important characteristics of Python Objects
- How to determine the type of instance and inheritance in Python
- How would you implement inheritance in Python?
- How is Inheritance and Overriding methods are related?
- How can you create a copy of an object in Python?
- How to avoid having class data shared among instances in Python?
- Static class variables in Python
- Difference between @staticmethod and @classmethod in Python
- How to Get a List of Class Attributes in Python
- Does Python supports interfaces like in Java or C#?
- What is used to create Unicode string in Python?
- What are differences between List and Dictionary in Python
- Different file processing modes supported by Python
- How do you append to a file in Python?
- What are the differences between the threading and multiprocessing?
- Is there any way to kill a Thread in Python?
- What is the use of lambda in Python?
- What is map, filter and reduce in python?
- Is monkey patching considered good programming practice?
- What is "typeerror: 'module' object is not callable"
- Python: TypeError: unhashable type: 'list'
- How to convert bytes to string in Python?
- What are metaclasses in Python?