2026-11-20 · 6 min read
How to draw with Python in the browser
A practical introduction to drawing with Python using draw: type real Python, press Run, and see an SVG canvas update instantly. No install required.
Python is a great first language, but most beginner exercises print text to a terminal. Drawing is more fun: you can see the result immediately, change one number, and watch the picture move.
draw is a free, in-browser Python drawing pad. It runs Python in your browser with WebAssembly, then turns the drawing commands into SVG. There is nothing to install and no account is required.
Your first drawing
Open the editor, type these lines, and press Run (or Ctrl+Enter):
background("#0b1020")
circle(400, 300, 120, fill="#2563eb", stroke="#93c5fd", stroke_width=4)
The first command fills the canvas. The second draws a circle from a centre point and a radius. The named values fill=, stroke=, and stroke_width= are keyword arguments.
Change one thing at a time
The fastest way to learn is to edit one value and run again. Try changing 400 to 300, then change the radius from 120 to 180. The canvas repaints straight away.
When the numbers get repetitive, store them in variables:
planet_x = 400
planet_y = 300
planet_r = 120
circle(planet_x, planet_y, planet_r, fill="#2563eb")
Why SVG?
SVG is a vector format. Unlike a screenshot, it stays crisp when you zoom in, and it can be saved, embedded in a web page, or printed. draw gives you drawing primitives (circles, rectangles, lines, paths, text) instead of pixels.
That means your Python program describes a picture, rather than painting individual pixels. It is a friendly way to practise functions, variables, loops, and lists while seeing a result.
Keep going
The 22-step Learn Python by drawing tutorial builds a complete planet scene from a blank canvas. Each step adds one new idea. You can start at step 1 or jump to variables, loops, or functions.
When you have made something you like, save it. Gallery drawings can be opened again and used as a starting point for your own scene.