- A Python dictionary stores associations between keys and values, allowing efficient data retrieval.
- Dictionaries can be created using the dict constructor or by declaring a dictionary with key-value pairs.
- Accessing dictionary items is done by indexing the dictionary with the key.
- Adding an item to a dictionary involves assigning a value to a new key.
- The get method retrieves the value associated with a key in a dictionary.
- Items can be removed from a dictionary using the pop method or the del
- The keys method retrieves all the keys in a dictionary, while the values method retrieves all the values.
- Python dictionaries are effective for tasks like word count, where each word is associated with its count.
- Sets in Python hold an unordered collection of unique values, automatically excluding duplicates.
- Sets are useful for membership-related tasks like checking if a value is in a set or finding common values.
- A set can be created using the set constructor or by using curly braces {}.
- Common set methods include add(), remove(), intersection(), and union().
- The pickle module in Python is used for serializing and deserializing Python objects.
- Serialization (pickling) converts a Python object into a byte stream for storage or transmission.
- Deserialization (unpickling) converts a byte stream back into a Python object.