Q2: What are the key operational differences between Lists and Tuples?
Lists are mutable sequence structures ([]), allocating extra memory over-allocation for dynamic resizing. Tuples are immutable sequence structures (()), occupying lower fixed memory footprint, faster allocation speeds, and supporting usage as dictionary keys.
Key Takeaways
- Lists = Mutable, higher memory overhead.
- Tuples = Immutable, lower memory, hashable (can be dict keys).
Knowledge Check
Can a tuple containing a list element be used as a key inside a Python Dictionary?