List vs Tuple in Python — Python Technical Interview Questions & Answers
List vs Tuple in Python
List vs Tuple in Python
- Both are ordered sequences. The big difference is mutability. List can change: append, pop, names[0] = "Asha". Tuple cannot. [] vs (). Tuple can be a dict key if its items are hashable; a list cannot. Pick list when you will edit. Pick tuple when the data should stay fixed — coordinates, RGB, a row you don’t want anyone to append to.
- Lead the viva with mutable vs immutable, then one use each. Don’t start with “tuple is faster” unless they ask — intent matters more for freshers.
- List vs Tuple in Python — output: [1, 2, 3] then (1, 2). List grew; tuple stayed.
point = (3, 4) immutable
x=3 y=4Technical Interview Tip: Mutability first; then dict-key use case.
Code Examples for List vs Tuple in Python
Example
# List vs tuple
a = [1, 2]
a.append(3)
b = (1, 2)
print(a)
print(b)
List vs Tuple in Python — output: [1, 2, 3] then (1, 2). List grew; tuple stayed.
How to Explain List vs Tuple in Python to an Interviewer
Explain List vs Tuple as if you are teaching a junior — definition, then one tiny script.
List mutable. Tuple immutable. [] vs ()
What does the example print, and why?
List vs Tuple in Python — output: [1, 2, 3] then (1, 2)
What mistake do freshers make with List vs Tuple?
Tuple can be dict key