Free Python Exercises
Beginner to Advanced
100+ hands-on Python coding exercises that run right in your browser. No install, no account. Write real Python and get instant feedback.
Start Practising Free →Variables & Data Types
Integers, floats, strings, booleans and type conversion.
String Manipulation
Slicing, f-strings, split, join, and common string methods.
If / Elif / Else
Conditionals, comparison operators, and boolean logic.
For Loops
Iterating over ranges, lists, and strings. break and continue.
While Loops
Condition-driven loops, counters, and accumulators.
Lists
Creating, indexing, slicing, append, sort, and list iteration.
Tuples & Sets
Immutable sequences, set operations, and membership testing.
Dictionaries
Key-value pairs, dict methods, and iterating over dicts.
Functions & Arguments
Default args, *args, **kwargs, return values, and scope.
List Comprehensions
Compact, readable list building with filtering and transformation.
Error Handling
try/except/finally, raising exceptions, and custom errors.
Classes & OOP
__init__, methods, inheritance, encapsulation, and polymorphism.
Higher-Order Functions
map, filter, reduce, and writing your own HOFs.
Generators & Iterators
yield, generator expressions, __iter__, __next__.
Decorators
Writing and applying decorators, functools.wraps.
Regular Expressions
Pattern matching, groups, re.search, re.findall, re.sub.
Dataclasses
@dataclass, field(), frozen, and comparison methods.
Context Managers
with statements, __enter__/__exit__, contextlib.
Closures
Lexical scope, factory functions, and the nonlocal keyword.
Enums
Enum, IntEnum, auto(), and using enums in real code.
__slots__ and Memory
Optimising class memory with __slots__ and understanding object layout.
Abstract Base Classes
ABC, abstractmethod, and structural subtyping with Protocol.
Why Python coding exercises beat tutorials
Reading about Python is easy. You nod along, the code in the examples makes sense, and you feel like you're making progress. Then you close the tab and open a blank file — and nothing comes out. This is the tutorial gap, and it's where most self-taught programmers get stuck.
The fix is deliberate practice: writing code from scratch, seeing it run or fail, and correcting it yourself. PyChallenge is built entirely around this loop. Every exercise gives you a blank editor, a clear goal, and instant feedback the moment you hit Run.
What makes a good Python exercise?
Good Python exercises share a few traits:
- One concept at a time. Exercises that mix five ideas at once teach you nothing reliably. PyChallenge focuses each problem on a single topic.
- Real output to verify. Not multiple choice, not fill-in-the-blank — your code either produces the right output or it doesn't.
- Hints that unblock without spoiling. If you're stuck, a hint nudges you forward. You still write the solution.
- Graduated difficulty. Easy exercises build the vocabulary. Medium exercises build fluency. Hard exercises build confidence.
Python exercises for beginners
If you're new to Python, the best exercises start with the absolute basics: printing output, assigning variables, and using strings. From there, work up to conditionals and loops. The goal at this stage isn't elegance — it's building a mental model of how Python executes code line by line.
Python exercises for intermediate developers
Once you're comfortable with the basics, the real power of Python opens up. List comprehensions, functions with *args and **kwargs, classes, and error handling are the topics that separate casual Python readers from developers who can actually build things. These are the topics where PyChallenge's intermediate track focuses.
Python exercises for advanced topics
Advanced Python — decorators, generators, metaclasses, dataclasses, context managers — is where most online resources run out of good exercises. PyChallenge covers these topics with hands-on problems that require you to write real implementations, not just recognise patterns.
Frequently asked questions
Do I need to install Python?
No. PyChallenge runs actual CPython in your browser via WebAssembly (Pyodide 0.25). Every exercise runs locally in your tab. There's no server, no install, and no account required.
Is PyChallenge free?
Yes. All exercises are free. You can use the app without signing up. Creating an account (also free) lets you save your XP and daily streak across sessions.
How many Python exercises are there?
PyChallenge currently has over 100 exercises across six tracks: Beginner, Intermediate, Advanced, Automation, Data, and Interview Prep. New exercises are added regularly.