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