Interactive Python Lab • Watch Code Run

Python Demo: See Your Code Run Line by Line

A Python program runs one line at a time. In this lab you pick a lesson, then step through it and watch each line change the variables, call functions, build objects and print output. Press Run to execute the same code in real Python in your browser.

How to use this lab

Play runs the program step by step, ← and → move one step, and clicking a line number jumps to that line. The code is read-only; use Copy code to try it in your own editor.

Animation speed
Lesson 01

Lesson

    demo.pyREAD-ONLY
    next line to runline just run
    Step 1 of 1line
    Frames & variables
    Printed output so far
    
                  

    Keys: ← → step back / forward, Space play / pause.

    Real Python • In Your Browser

    Run the Code in Real Python

    Run executes the selected lesson in real Python (Pyodide) right in your browser. The first run downloads Python, about 10 MB.

    Python: not started
    
            
    Practice • Think Like Python

    Explore

    Things to watch for while you step through this lesson.

      Want to learn Python from scratch? The Python Foundations course covers it lesson by lesson.