List #
- Sorting and Searching
- Write a function that sorts a list of strings based on their lengths in descending order.
- Implement a binary search function that finds the position of a target value within a sorted list.
- List Comprehensions with Conditions
- Use a list comprehension to generate a list of all prime numbers between 1 and 100.
- Manipulating Large Lists
- Given a large list of integers, write a function to find the top 5 largest numbers in the list without sorting the entire list.
- Flattening Nested Lists
- Write a function to flatten a nested list of arbitrary depth (e.g.,
[[1, [2, 3]], [4, [5, [6, 7]]]]
should become[1, 2, 3, 4, 5, 6, 7]
).
- Write a function to flatten a nested list of arbitrary depth (e.g.,
- Finding Common Elements
- Write a function that takes two lists and returns a list of elements that are present in both lists, without using sets.
Set #
- Advanced Set Operations
- Given two sets, write a function to find the Cartesian product of the sets.
- Handling Large Datasets
- Given a large dataset of integers with potential duplicates, write a function to find all unique elements and their frequencies.
- Set Comprehensions
- Use a set comprehension to create a set of all unique characters in a given string, ignoring case.
- Set Operations on Multiple Sets
- Write a function that takes a list of sets and returns a set that is the union of all the sets.
- Performance Comparison
- Compare the performance of finding the intersection of two large lists using set operations versus list comprehensions.
Dictionary #
- Complex Key-Value Pair Manipulation
- Given a dictionary where keys are strings and values are lists of integers, write a function to find the key with the highest sum of its values.
- Merging Dictionaries
- Write a function to merge two dictionaries. If a key exists in both dictionaries, the value should be a list containing both values.
- Dictionary Comprehensions with Conditions
- Use a dictionary comprehension to create a dictionary from a list of strings, where the keys are the strings and the values are the lengths of the strings, but only include strings longer than 3 characters.
- Nested Dictionary Manipulation
- Given a nested dictionary representing a company structure (e.g.,
{'CEO': {'VP1': {'Manager1': {}, 'Manager2': {}}, 'VP2': {'Manager3': {}}}}
), write a function to add a new employee under a specific manager.
- Given a nested dictionary representing a company structure (e.g.,
- Complex Data Aggregation
- Write a function that takes a list of dictionaries representing sales data (e.g.,
{'product': 'A', 'quantity': 10, 'price': 5}
) and returns a dictionary with total sales for each product.
- Write a function that takes a list of dictionaries representing sales data (e.g.,
Tuple #
- Tuple Operations
- Write a function that takes a list of tuples (representing coordinates) and returns the tuple with the maximum Euclidean distance from the origin.
- Unpacking with Patterns
- Given a list of tuples representing student records (e.g.,
[(name, age, grade)]
), write a function to unpack and process the data to calculate the average grade.
- Given a list of tuples representing student records (e.g.,
- Using Tuples in Data Structures
- Create a function that takes a list of tuples representing edges in a graph (e.g.,
[(node1, node2)]
) and returns an adjacency list representation of the graph using dictionaries.
- Create a function that takes a list of tuples representing edges in a graph (e.g.,
- Tuple as Dictionary Keys
- Write a function that counts the frequency of each unique tuple in a list of tuples and stores the result in a dictionary.
- Advanced Unpacking Techniques
- Given a tuple of nested tuples (e.g.,
((1, 2), (3, (4, 5)), 6)
), write a recursive function to flatten the tuple into a list.
- Given a tuple of nested tuples (e.g.,