Python Tuples: Ordered, Immutable Data Type

🚀 Day 15 – Python Learning Journey 📌 Topic: Tuples & Tuple Methods Today I learned about Tuples in Python. 🔹 What is a Tuple? A tuple is a collection data type in Python. Ordered ✅ Immutable (cannot change after creation) Allows duplicate values  Tuple Methods (Only 2 Methods) Unlike lists, tuples have only 2 built-in methods: 1️⃣ count() Returns the number of times a value appears. numbers = (1, 2, 3, 2, 4, 2) print(numbers.count(2))   # Output: 3 2️⃣ index() Returns the first occurrence index of a value. numbers = (10, 20, 30, 40) print(numbers.index(30))   # Output: 2 ✔ Packing & Unpacking 🎯 Key takeaway: Tuples are faster and useful when data should not change. #Python #CodingJourney #100DaysOfCode #WomenInTech #LearningDaily

To view or add a comment, sign in

Explore content categories