🐍
Python
Python Interview Question Bank — Data Engineer Edition
🐍
🐍
Python · Section 4 of 5

Python Interview Question Bank — Data Engineer Edition

🔒

This section is locked

Unlock every deep-dive, lab, mock interview, and memory map across all 10 topics.

View Plans — from ₹299/month

Already have a plan? Sign in

Python Interview Question Bank — Data Engineer Edition

Pro Tip
Quick-fire questions that interviewers ask to check your Python fundamentals. Each question includes multiple code examples, clear outputs, and interview tips.

Q01 — What is the difference between a list and a tuple?

Question: Explain the key differences between lists and tuples in Python. When would you use each?

Quick Answer: Lists are mutable (changeable), tuples are immutable (fixed). Tuples are faster, use less memory, and can be used as dictionary keys.

python — editable
# Example 1: Mutability difference
my_list = [1, 2, 3]
my_list[0] = 99        # Works fine — lists are mutable
print(my_list)
# Output: [99, 2, 3]

my_tuple = (1, 2, 3)
# my_tuple[0] = 99     # Raises: TypeError: 'tuple' object does not support item assignment
print(my_tuple)
# Output: (1, 2, 3)
python — editable
# Example 2: Tuples as dictionary keys (lists cannot do this)
# Tuples are hashable because they are immutable
coords = {(10, 20): "New York", (40, 50): "London"}
print(coords[(10, 20)])
# Output: New York

# Lists are NOT hashable — this would fail:
# bad_dict = {[10, 20]: "New York"}
# Raises: TypeError: unhashable type: 'list'
python — editable
120 bytes
print(f"Tuple size: {sys.getsizeof(my_tuple)} bytes")
# Output: Tuple size: 80 bytes
# Tuples use less memory because they don't need resize overhead"># Example 3: Memory and performance comparison
import sys

my_list = [1, 2, 3, 4, 5]
my_tuple = (1, 2, 3, 4, 5)

print(f"List size:  {sys.getsizeof(my_list)} bytes")
# Output: List size:  120 bytes
print(f"Tuple size: {sys.getsizeof(my_tuple)} bytes")
# Output: Tuple size: 80 bytes
# Tuples use less memory because they don't need resize overhead

🎯 Tip: "Tuples are hashable so they can be dict keys. Lists cannot because they're mutable. I use tuples for fixed data like DB row results or coordinates."

Q02 — What are Python's mutable and immutable types?

Question: Name Python's mutable and immutable types. What happens when you modify an immutable object?

Quick Answer: Immutable types (int, float, str, tuple, frozenset, bytes) create a new object on