Dictionaries

Dictionaries are collections of key-value pairs. Each key in a dictionary is unique and maps to a value. Dictionaries are created using curly braces {} or the dict() function. # Creating a dictionary of names and ages my_dict = {“Alice”: 25, “Bob”: 30, “Charlie”: 35} # Creating a dictionary of stock prices stock_prices = {“AAPL”: … Read more

Sets

Sets are unordered collections of unique elements. Sets are created using curly braces {} or the set() function. # Creating a set of integers my_set = {1, 2, 3, 4, 5} # Creating a set of strings my_strings = set([“apple”, “banana”, “cherry”]) Sets support mathematical set operations such as union, intersection, and difference. # Set … Read more

Tuples

Tuples are similar to lists, but they are immutable, which means their elements cannot be changed. Tuples are created using parentheses (). # Creating a tuple of integers my_tuple = (1, 2, 3, 4, 5) # Creating a tuple of strings my_strings = (“apple”, “banana”, “cherry”)   Tuples can be accessed and sliced in the … Read more