Overview of my main takeaways from my **Week 8** learning on Data structures(Tuples and Dictionaries) from Blockfuse Labs:
**Instructor: Mr. Bankat.**
# **Tuples**
**Definition of a Tuple**: A tuple is an ordered and immutable set of values.
***Example***: dimensions = (1920, 1080)
**Immutability**: Once created, tuples cannot be modified (no adding, deleting, or altering values).
**Data Types**: Tuples can hold varied data types, e.g., employee = ("Jane", 30, False)
***Use Case***: Ideal for protecting data from alterations, such as screen resolutions or returning multiple outputs from functions.
***Mini Project Example***: A dictionary using tuples as values:
``` python
books = {
"Chike and the River": ("Chinua Achebe", 180)
"Rich Dad Poor Dad": ("Robert T. Kiyosaki", 328),
"To Kill a Mockingbird": ("Harper Lee", 281),
}
print{books}
```
# **Python Dictionaries**:
**Definition of a Dictionary**: A collection of unique key-value pairs that is unordered, with immutable keys.
***Example***:
``` python
car = {
"brand": "Toyota",
"model": "Corolla",
"year": 2020
}
```
**Key Concepts:**
Access values by using their keys (e.g., car["brand"] yields "Toyota").
**Methods**:
**.keys():** Provides a list of all keys.
**.values():** Provides a list of all values.
**.items():** Provides all key-value pairs.
*Use Case:* Perfect for handling data that requires distinct identifiers, such as vehicle information records.
# Conclusion
This week improved my understanding of structured data management in Python. Mr. Bankak explained concepts clearly with practical examples and exercises. I feel more confident using dictionaries and tuples in my projects.
**Written By: Zokdat Elkanah.**