main.py
Templates:
1
Ln 1, Col 1 0 chars Saved locally
Spaces: 4 UTF-8 Python 3.12
⚡ Ready
No Output Yet
Click "Run" or press Ctrl + Enter to execute your Python script.
No Plots Generated
Generate Matplotlib figures and they will automatically render here!

When your script calls input(), it reads values from here one line at a time. Enter each answer on a new line before running:

0 lines
Variable Inspector
Top-level variables created during script execution will appear here.
Install Pure-Python Package via micropip

Install pure Python packages directly from PyPI into your browser environment:

Pre-bundled Scientific Packages (Auto-loaded on import)
numpy ✓ Ready
pandas ✓ Ready
matplotlib ✓ Ready
scipy ✓ Ready
scikit-learn ✓ Ready
sympy ✓ Ready
regex ✓ Ready
sqlite3 ✓ Ready

Keyboard Shortcuts

Ctrl + Enter (or Cmd + Enter)Run Python script
Ctrl + SDownload current script (.py)
Ctrl + FFind & replace in editor
F1Open editor command palette
Tab / Shift + TabIndent / Dedent code (4 spaces)
EscDismiss modal or notification

Privacy & Architecture

This playground runs 100% locally in your browser using WebAssembly (Pyodide v0.27.3).

  • Your code is never transmitted to an external execution server.
  • Execution occurs in a Web Worker, ensuring high responsiveness and allowing instant interrupts (Stop).
  • Matplotlib figures are automatically captured and rendered directly inside the Visuals tab.
  • Multi-file support enables creating helper modules and importing them seamlessly.

Write and Run Python Code in Your Browser

Python Playground lets you write and run Python code in your browser, then view its text output or error messages. Use it to practise programming concepts or test small scripts without installing Python.

Enter your code, supply any input answers, and run the program. Execution happens locally in your browser, while internet access is needed to load the Python runtime.

How to Use This App

  • Enter your Python code in the editor or select a built-in example.
  • Add answers in the Program input box if your code uses input(), placing one answer per line.
  • Click Run Python or press Ctrl + Enter on Windows or Command + Enter on Mac.
  • Review the output panel for printed results or error messages.
  • Edit your code and run it again to test your changes.
  • Click Stop if your program keeps running or enters an infinite loop.
  • Click Save .py to download your code as a Python file.

Examples and Use Cases

  • Test a calculation: Enter print(15 * 4) and run the program. The output panel displays 60.
  • Practise loops: Select the “Hello, Python” example to print the squares of numbers 1 through 5. Change the range to explore more numbers.
  • Use program input: Select “Using input()” and enter Alex and 12 on separate lines in the Program input box. The program greets Alex and reports that next year they will be 13.
  • Understand an error: Run print(10 / 0) to see a ZeroDivisionError. Change the divisor to 2 and run again to display 5.0.
  • Explore classes: Select the “Classes” example to simulate withdrawing money from a bank account. Try different withdrawal amounts to test successful transactions, invalid amounts, and insufficient funds.

Helpful Details

Common Python Mistakes

  • No visible result: Use print() to display values. Assigning a value to a variable does not produce text output.
  • Indentation errors: Indent the statements inside loops, functions, classes, and conditional blocks consistently.
  • Input errors: Each input() call consumes one line from Program input. Missing answers cause EOFError, while converting nonnumeric text with int() causes ValueError.

Execution and Output Limits

Each run starts with fresh Python variables. Temporary files and imported module state may remain until you stop the runtime or reload the page. Output is limited to 100,000 characters per run; reaching this limit does not stop the program.

This version displays text output rather than plots. Desktop interfaces, server sockets, and some Python packages are not supported.

Saving Your Work and Privacy

Browser draft saving is convenient but is not a permanent backup. Download important code with Save .py, especially before clearing browser data or switching devices.

The app does not send your code to an execution server. However, code you run can make network requests, so review unfamiliar code before executing it.

Frequently Asked Questions

Do I need to install Python to use this app?

No. Python runs directly in your browser. Internet access is required to load the Python runtime and any supported packages your code needs.

How do I provide answers for input()?

Enter your answers in the Program input box before running your code, with one answer per line. Each input() call reads the next line. If there are not enough answers, the program raises EOFError.

Why does my program show no output?

Assignments and calculations do not automatically display results. Use print() to show values in the output panel, such as print(2 + 3).

Can I use any Python library?

The app supports Python’s standard library and compatible packages available through Pyodide. Some packages require additional downloads. Desktop interfaces, server sockets, and arbitrary native packages are not supported.

How do I stop an infinite loop?

Click Stop to terminate execution and discard the Python runtime. Your code remains in the editor, and the runtime reloads when you run it again.

Will my code be saved?

The app automatically saves your draft when browser storage is available. This is not a permanent backup and does not sync across devices. Use Save .py to download a copy of your code.