🐍 Python Tuples for Beginners
📚 Table of Contents
- What is a Tuple?
- Creating a Tuple
- Accessing Tuple Elements
- Tuple Operations
- Tuple Methods
- Difference Between List and Tuple
- Practice Examples
- FAQ
💡 Quick Tip
Use tuples when you don't want your data to be changed accidentally.
⚠️ Common Mistakes
- Using square brackets instead of parentheses.
- Trying to update tuple values.
- Forgetting comma in single element tuple.
✍️ By Roshni Code Charm
📅 July 2026 | ⏱️ 5 min read
🐍 What is a Tuple?
A tuple is a collection of multiple values stored in a single variable.
Tuples are ordered and cannot be changed after creation.
Creating a Tuple
numbers = (10,20,30)
print(numbers)
Accessing Tuple Elements
Tuple elements are accessed using index numbers.
Index starts from 0.
colors = ("Red","Blue","Green")
print(colors[1])
Tuple with Different Data Types
student = ("Roshni",18,True)
print(student)
Tuple Operations
- + - Join two tuples
- * - Repeat tuple values
- in - Check value exists
- len() - Find tuple size
✨ Tuple Methods
- count() - Counts occurrence of a value
- index() - Finds position of a value
🔄 List vs Tuple
-
List: Mutable (can be changed)
-
Tuple: Immutable (cannot be changed)
-
List: Uses []
-
Tuple: Uses ()
🚀 Practice Example
languages = ("Python","HTML","CSS")
print(languages)
print(languages[0])
❓ Frequently Asked Questions
1. Are tuples changeable?
No, tuples cannot be modified after creation.
2. Which brackets are used for tuples?
Parentheses () are used to create tuples.
3. Why use tuples?
Tuples are faster and safer for storing fixed data.