Free · Runs in your browser · No install
Free Python lessons
Short lessons, from your first print() to advanced Python. Edit and run every example right here, then try a “Your turn” task that checks your output.
Popular:
Free account: saved progress, AI hints, streaks and badges. Create your free account →
Where do you want to start?
Free course
Python Fundamentals
Never coded before? Follow the Python Fundamentals course from your first print() to functions, lists and dictionaries.
31 lessons · 37 exercises in Python Fundamentals that check your code
- Printing Output
print() displays a value on the screen. It is how you see what your program is doing.
- Variables
A variable is a name that stores a value. You create one with =, then use the name to get the value back later.
- String Formatting
A string is a text value written inside matching quotes. An f-string lets you insert values into text by putting them inside {}.
- Reading Input
input() waits for someone to type an answer and press Enter. It gives your program that answer as text. Store it in a variable so you can use it later.
- Data Validation
Data validation checks that data follows your rules before you use it, such as "a whole number from 0 to 120".
- Data Types and Operations
Python numbers come in two data types: integers for whole numbers like 7, and floats for decimals like 3.75. Arithmetic operators do maths with them.
Python fundamentals
Practise these in the free Python Fundamentals course →
Printing output
- Printing Output2 exercises
Variables
- Variables3 exercises
User input
- Reading Input2 exercises
Strings
- String Formatting5 exercises
- String Methods4 exercises
Arithmetic
Comparisons and logical operators
- Comparisons and Logical Operators4 exercises
- Membership Testing1 exercise
Indexing
- Indexing3 exercises
Lists
- Lists3 exercises
- Change a List Item by Index
- Unpacking Values5 exercises
- Nested Data2 exercises
- Nested Lists: Make a Grid in Python
Defining functions
- Defining Functions2 exercises
if / elif / else
- if, elif, else6 exercises
while loops
for loops
- For Loops8 exercises
- The range() Function6 exercises
- The Accumulator Pattern4 exercises
- break and continue1 exercise
- Tracking the Best Candidate1 exercise
Dictionaries
Parameters & return
- Parameters & Return5 exercises
- Stopping a Search with return6 exercises
Nested loops & ifs
Decomposition
Data validation
Tracing code
- Tracing Code1 exercise
Debugging
- Debugging2 exercises
More lessons
- Logical Operators — merged lesson
- Numbers and Math
- Random Numbers in Python1 exercise
- Minimum, Total and Average
- Python Read File: Reading Text Files3 exercises
- Python Set Operations: Intersection, Union and Difference
- Sets and Tuples1 exercise
- Python Sorting: sorted() with reverse and key1 exercise
- SQL AND
- SQL BETWEEN
- SQL Comparison Operators
- SQL COUNT and AS
- SQL IN and NOT IN
- SQL LIKE
- SQL DESC and LIMIT
- SQL OR
- SQL ORDER BY
- SQL SELECT and FROM
- SQL WHERE
Turtle Graphics
Practise these in the free Python Basics with Turtle course →
- Turtle graphics in Python
Turtle graphics is Python's way to draw: a turtle is a pen you steer with commands like forward() and left(), and it draws a line wherever it goes.
- Turtle backward(): going back to the start
backward() moves the turtle back the way it came, undoing a forward(). With right() to undo a left(), you can bring the turtle back to its start.
- Turtle coordinates: goto() and position()
Turtle coordinates are the x and y numbers for each point in the turtle window. (0, 0) is the centre, x grows to the right and y grows upwards.
- penup() and pendown()
penup() lifts the turtle's pen so it moves without drawing, and pendown() puts the pen back down so it draws again.
- Turtle colours: pencolor(), pensize() and bgcolor()
pencolor() sets the colour of the lines a turtle draws, pensize() sets how thick they are, and bgcolor() colours the window behind them.
- Filling shapes: begin_fill() and end_fill()
A turtle fill colours in a shape: start the fill, draw the shape, end the fill, and the turtle paints the area inside its moves with its fill colour.
- Drawing shapes with turtle loops
A for loop draws a turtle shape by repeating one side: the same forward() and left() run again for every side, so a square takes three lines, not eight.
- Turtle circles: circle() and dot()
circle(radius) makes the turtle drive round a circle, and dot(size) puts a round, filled spot where the turtle stands.
- Turtle text and stamps: write(), shape() and stamp()
write() puts text on the turtle window, shape() changes what the turtle looks like, and stamp() leaves a copy of that shape behind.
- The turtle screen: Screen(), speed() and tracer()
turtle.Screen() gives you the turtle window itself. Use it to set the window's title, size and colour, to control drawing speed, and to hold several turtles.
Advanced concepts
A free account saves your progress and gives AI hints in every course →
Printing Output
Variables and Assignment
Numbers and Arithmetic
Working with Lists
Working with Dictionaries
Working with Strings
Reading Input
Data Validation
Comparisons and Booleans
For Loops
Nested Loops & Ifs
While Loops
The range() Function
The Accumulator Pattern
Stopping a Search
Making Decisions
Random Numbers
Debugging
Iteration and Functional Tools
- Python Iterators: iter(), next() and How for Loops Work
- Python Generators: Your First Generator and next()1 exercise
- Python yield: Write a Generator Function1 exercise
- Infinite Generators in Python: Running State1 exercise
- Python Generator close(): Stopping a Generator1 exercise
- Python Generators and yield: Lazy Iteration Explained
- Python Generator in a for Loop: StopIteration Explained1 exercise
- Python yield vs return: Lazy Evaluation with Generators1 exercise
- Python Generator Function: Filter Lines with yield1 exercise
- Python Generator Pipeline: Take First N Items (islice)1 exercise
- Python Read File Line by Line with a Generator1 exercise
- Parse a Log File in Python with Generators1 exercise
- Python enumerate(): Loop with Index and Value3 exercises
- Python zip(): Loop Over Lists Together1 exercise
- Python Lambda Functions Explained with Examples
- Python map() and filter() (and When to Use a Comprehension)
Comprehensions
Functions, Closures and Decorators
Modules and Imports
Files and JSON
Web APIs
- API basics with requests5 exercises
- Inspecting API responses4 exercises
Dates and Times
Regular Expressions
Object Oriented Programming
- Python Classes and Objects: __init__ and Instances3 exercises
- Python Methods and self: Reading and Changing Object State2 exercises
- Python Inheritance: Subclasses and Parent Classes
- Python super() and Method Overriding Explained
- Python Dataclasses: @dataclass, Defaults and Free Methods5 exercises
- Python Dataclass Methods: Add Behaviour to Fields3 exercises
- Python OOP Composition with Dataclasses: Objects Inside Objects2 exercises
- Python Dataclass Validation with __post_init__2 exercises
- Python Frozen Dataclasses and replace2 exercises
- Python Dataclass Inheritance and Polymorphism2 exercises
- Python Dataclass asdict Examples1 exercise
- Dataclasses vs Pydantic
Exceptions and Error Handling
Context Managers
Type Hints and Protocols
The Agent Game
Put your Python to work
Write an agent that plays a strategy game, then watch it take on our bots. No account needed.
- Play Greedy Pig →
Play Greedy Pig, the push-your-luck dice game, by writing a Python agent that decides when to bank. Edit, run and test it free in your browser — no sign-up.
- Play Lineup 4 →
Write a Python agent that plays Lineup 4, a connect-four game, and test it against five bots free in your browser — no sign-up, no install.
Ready to practise? Start the free Python course
Create a free learner account and work through the courses at your own pace. 100% free, no credit card.
- Exercises that check your code instantly
- Saved progress, streaks and badges
- AI hints when you get stuck
- Program agents that play strategy games