๐Ÿ“ฑ Code Python on your phone with Python Coding - Learn PythonGet the free Android app โ†’
  1. Home
  2. Python exercises

Practice ยท 36 exercises

Python exercises for beginners (with solutions)

Practise Python by writing real code. Every exercise runs in your browser and is checked automatically against test cases, with a hint and a worked solution when you need them. Your progress is saved on this device.

How it worksPick a topic, read the task, write your code in the editor and press Check. The tests run your program with real inputs and tell you exactly which case passed or failed โ€” no account needed.

0 / 36 solved

Topics and order

Work through the topics in order if you are new to Python โ€” each one only uses ideas from the topics before it.

TopicExercisesCovers
Python basics6print(), variables, input(), int/float, arithmetic, f-strings
String exercises6indexing, slicing, methods (upper, split, join, replace), counting, palindromes
List exercises6indexing, append, sum/min/max, sorting, comprehensions, removing duplicates
Loop exercises6for, while, range, nested loops, break, patterns, prime numbers
Function exercises6def, parameters, return values, default arguments, recursion
Dictionary exercises6dict creation, get, loops over items, counting, grouping, inverting, nested data

Why practise with auto-checked exercises?

Reading code feels like learning, but you only find the gaps when you write it yourself. Automatic tests give you the same feedback a teacher would: they try your program with several inputs, including edge cases like an empty list or a negative number, and show you the exact output you produced next to what was expected.

Stuck? Paste your attempt into the Python code visualizer to watch it run line by line, or the syntax checker to find typos.

12 more marked exercises in the app

Python Coding - Learn Python for Android: a real Python 3 interpreter, code editor, 26 example programs and 12 marked exercises.

Get it on Google Play

Frequently asked questions

Where can I practise Python online for free?

Right here. Every exercise on coding-python.com runs real Python in your browser and checks your answer automatically โ€” free and without an account.

Do I need to install Python?

No. The exercises use Python running inside your web browser, so they work on a laptop, Chromebook, tablet or phone.

Are the solutions included?

Yes. Each exercise has a hint and a full worked solution with an explanation. Try first โ€” you learn far more by attempting it.

Is my progress saved?

Yes, solved exercises and your code are saved in this browser. Clearing site data resets them.

What should I do after these exercises?

Build something: try the Python games, then small projects from the cheat sheet ideas, or practise on your phone with the app.