π Python Mastery Challenge Set
Master these 25 challenges and you'll be ready for Django, Selenium, and beyond!
How to Use This Guide
If you can confidently solve all these challenges even years from now, you'll know your Python fundamentals are rock-solid. Work through them in order β each level builds on the previous one.
Time Investment: Plan for 2-3 hours total if you're focused, or spread it over several days.
Level 1: Data Structures Mastery
Foundation Level β Get comfortable with Python's core data types
Challenge 1: List Manipulation Master
Write a function that takes a list of numbers and returns a new list where:
β All even numbers are doubled
β All odd numbers are squared
β Remove any results greater than 100
β Sort the final list in descending order
Example: [1, 2, 3, 4, 15] should become [36, 8, 4, 1]
Skills tested: List comprehensions, filtering, sorting, mathematical operations
Challenge 2: Dictionary Detective
Create a function that analyzes student data stored as a list of dictionaries: β Find the student with the highest average grade β Count how many students are in each grade level β Return only students who have ALL grades above 80
Sample data format:
students = [
{"name": "Alice", "grades": [85, 92, 78], "level": "junior"},
{"name": "Bob", "grades": [90, 88, 95], "level": "senior"}
]
Skills tested: Dictionary manipulation, nested data access, aggregation functions
Challenge 3: Set Operations Wizard
Given multiple lists of user IDs from different social media platforms: β Find users present on ALL platforms β Find users unique to EACH platform β Suggest βfriends you may knowβ (users on 2+ platforms but not all)
Skills tested: Set operations (union, intersection, difference), logical thinking
Challenge 4: Tuple Transformation
Work with coordinate data stored as tuples (x, y):
β Calculate distances between all pairs of points
β Find the two closest points
β Group points by which quadrant they're in
β Sort points by their distance from the origin
Skills tested: Tuple unpacking, mathematical calculations, grouping data
Challenge 5: Nested Structure Navigator
Parse a nested dictionary representing a company's organizational structure: β Count total number of employees β Find all people who are managers β Calculate average salary per department β Determine the deepest level of nesting in the structure
Skills tested: Recursive thinking, nested dictionary traversal, data aggregation
Level 2: Functions & Advanced Logic
Intermediate Level β Master Python's functional programming features
Challenge 6: Decorator Factory
Create a decorator that can: β Time how long a function takes to run β Log every time the function is called (with its arguments) β Cache results to avoid recalculating expensive operations β Handle any exceptions that occur gracefully
Skills tested: Decorators, error handling, caching concepts, function introspection
Challenge 7: Lambda & Higher-Order Functions
Using ONLY lambda functions along with map(), filter(), and reduce():
β Process a list of employee dictionaries
β Chain multiple data transformations together
β Create a mini data processing pipeline
Restriction: No regular function definitions allowed β only lambdas!
Skills tested: Functional programming, lambda expressions, built-in functions
Challenge 8: Recursive Problem Solver
Write recursive functions to solve: β Generate all possible permutations of a string β Find all paths through a simple maze (represented as a 2D list) β Calculate the nth Fibonacci number with memoization
Skills tested: Recursion, memoization, backtracking algorithms
Challenge 9: Generator Guru
Create generators that: β Produce an infinite sequence of prime numbers β Read and process a large file line by line without loading it all into memory β Generate all combinations of items from multiple lists
Skills tested: Generators, memory efficiency, yield statements
Challenge 10: Context Manager Creator
Build a custom context manager that: β Automatically manages database connections β Times code execution and prints the duration β Temporarily changes a global setting and restores it afterward
Skills tested: Context managers, __enter__ and __exit__ methods, resource ma