Coding Challenges
Standalone coding challenges to sharpen your Python skills. Each challenge is a single file with a problem description, function stub, hints, and built-in tests.
How It Works
Read the docstring at the top of each challenge file for the problem description and examples.
Implement the function where it says pass.
Run the file with python <filename>.py -- the built-in tests will tell you if your solution is correct.
Check the solution in solutions/ only after you have genuinely attempted the problem.
Difficulty Levels
Level
Description
Prereqs
Beginner
Core Python: variables, strings, lists, loops, conditionals
Level 0-2 of the curriculum
Intermediate
Decorators, generators, classes, async, file I/O, data structures
Level 3-6 of the curriculum
Directory Structure
challenges/
README.md -- This file
beginner/ -- 15 beginner challenges
intermediate/ -- 15 intermediate challenges
solutions/
beginner/ -- Beginner solutions with explanations
intermediate/ -- Intermediate solutions with explanations
Tips
Read the entire docstring before writing any code.
Use the hint only if you are stuck for more than 5 minutes.
Run the tests frequently as you build up your solution.
If all tests pass but you are unsure why, trace through your code by hand with the example inputs.
Compare your passing solution to the provided solution -- there are often multiple valid approaches.
Estimated Time
Beginner challenges: 10-30 minutes each
Intermediate challenges: 30-60 minutes each