Q1.What is the difference between a list and a tuple in Python? When would you use each?
- â¸Lists are mutable (can be changed after creation); tuples are immutable.
- â¸Use lists for collections that need to change (e.g., adding items). Use tuples for fixed data (e.g., RGB values, DB row records).
- â¸Tuples are faster to iterate and are hashable, so they can be used as dictionary keys.