Python practice
Practice Python online: 10 exercises, graded problems and a playground
The Python here is real CPython, compiled to WebAssembly by the Pyodide project and loaded into your browser tab — so print, input, f-strings, lists and dictionaries behave exactly as they do on your own machine. The exercises start from a program that already works and ask you to fix or extend one thing; the playground is a blank editor for whatever you want to try next.
- checked exercises
- 10
- graded problems
- 24
- lessons
- 9
- cheat sheet
- 1
Python practice exercises
How the path works →In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.
- Hello, Out Loudprint() puts text on the screen
- Name TagA variable is a reusable name for a value
- Party PlannerPython does arithmetic with + - * // and %
- Umbrella or Notif/else chooses between two different outcomes
- CountdownA for loop with range() repeats an action
- The Clapping GameAn if inside a for loop, decided again on every pass
- The Scoreboardf-strings build text with values inside it
- Packing ListA list holds several values in order, and a for loop walks through them
- Rainfall WeekA variable made before a loop carries a running total from pass to pass
- The Cafe TicketAssembling a complete program from parts you already know
Graded Python practice problems
Checked against hidden test cases — the step up from the exercises. Some are debugging labs: the program is already broken, and the job is to find out why.
- Balanced Parentheseseasy · dsa
- Best Contiguous Runeasy · dsa
- Binary Searcheasy · dsa
- Binary Tree Level Order Sumeasy · dsa
- Class Average To Two Decimalseasy · debugging
- Count The Target Ticketeasy · debugging
- Group Word Clusterseasy · dsa
- Largest Gap Between Readingseasy · debugging
- Lowest Reading Of The Dayeasy · debugging
- Reverse Words in a Stringeasy · dsa
- Two Number Sumeasy · dsa
- Valid Palindromeeasy · dsa
- Cycle in a Sequence Chainmedium · dsa
- Longest Stretch Without a Repeatmedium · dsa
- Longest Win Streakmedium · debugging
- Merge Overlapping Bookingsmedium · dsa
- Nth Fibonacci Number (Memoized)medium · dsa
- Strictly Increasing Checkmedium · debugging
- Top Three Scoresmedium · debugging
- Warmer Day Countdownmedium · dsa
- Widest Water Tankmedium · dsa
- Fewest Coins for Amounthard · dsa
- Long Words Per Linehard · debugging
- Shortest Hop Counthard · dsa
Python lessons behind the practice
All lessons →- Python Printing and OutputLearn what print really does in Python - quotes and strings, printing values with commas, the sep and end settings, escapes and multi-line text.
- Python Variables and Data TypesUnderstand what a Python variable really is, how to name one well, and how int, float, str, bool, and None behave when you check and convert types.
- Python Arithmetic and NumbersHow Python does maths - why division always gives a float, what // and % really answer, powers, int versus float, and why 0.1 + 0.2 is not 0.3.
- Python Conditionals: if, elif, and elseLearn how Python decides what to run using if, elif, and else, plus comparison operators, and/or/not, truthiness, and the conditional expression.
- Python For Loops and IterationLearn Python for loops from the ground up - iterate over lists and strings, use range, enumerate and zip, and steer a loop with break and continue.
- Python StringsLearn how Python strings are created, why they are immutable, how indexing and slicing work, and the string methods and f-string formatting you will use most.
- Python ListsLearn how Python lists store ordered, changeable collections of values, and how to create, access, modify, and iterate over them.
- Python Functions: Defining, Calling, and ReturningLearn Python functions from scratch - def syntax, parameters versus arguments, return values, keyword and default arguments, *args, **kwargs, and scope.
- Python DictionariesLearn how Python dictionaries map keys to values, read them safely with .get(), add, update and delete entries, loop with .items(), and why lookups are fast.
Python cheat sheet
Everyday syntax on one page, for when you remember the idea but not the spelling.
Coding interview questions
Original questions with full model answers, for when the practice is going somewhere specific.
Questions people ask
- Is this the real Python, or a simplified version?
- Real CPython, the standard Python interpreter, compiled to WebAssembly by Pyodide. Standard-library modules like math, random, json and collections are available; packages that need a network or a real filesystem are not.
- Can I practise input() and reading from the user?
- Yes. Type the lines your program should read into the input box beside the editor, one per line, and input() reads them in order when you press Run.
- Do I need to install Python to use these exercises?
- No. All 10 exercises, the lessons, the cheat sheet and the playground run in the browser with nothing installed and no account. The Python guide explains how to set up a local install when you want one.
- Where do I go once the beginner exercises feel easy?
- The graded practice problems are checked against hidden test cases and include debugging labs where the program is already broken. After those, the Python lessons go deeper on each idea, and the coding interview questions show what employers actually ask.
Practise another language
The same kind of practice hub exists for JavaScript, TypeScript, Java, C++, C, C#, Go, PHP, Ruby, SQL, R and Bash & the Shell.