What is a Tuple? A tuple in Python is like a list , but with one big difference, Tuples are immutable — once created, you cannot change, add, or remove elements. Think of it like a sealed box, you can look inside and take items out, but you can’t replace or rearrange them. Creating Tuples Accessing Tuple Items Just like lists, tuples use zero-based indexing : Why Tuples are Useful Immutability → safer for data you don’t want changed. Faster than lists (because fixed size and immutable). Hashable → can be used as keys in dictionaries or elements in sets (lists cannot). Tuple Methods Since tuples are immutable, they have fewer methods than lists: Packing and Unpacking Tuple vs List (Quick Comparison) Feature List ( [] ) Tuple ( () ) Mutability Mutable Immutable Performance Slower Faster Methods Many Few Use case When data may change When data should stay fixed Key Takeaways : Tuples are immutable, ordered, allow duplicates . Great for fixed collections of data . Support packing/unpacking and can be used as dictionary keys.
What is a Tuple?
Creating Tuples
Accessing Tuple Items
Just like lists, tuples use zero-based indexing:
Why Tuples are Useful
Tuple Methods
Since tuples are immutable, they have fewer methods than lists:
Packing and Unpacking
Tuple vs List (Quick Comparison)
[])())Key Takeaways: