Running Code
How code execution works in the browser.
How It Works
Your code runs directly in your browser using Pyodide, a Python interpreter compiled to WebAssembly. This means:
- No server needed — Code executes locally
- Instant feedback — No waiting for a server response
- Privacy — Your code stays in your browser until you submit
Execution Flow
Click "Run Code"
↓
Pyodide parses your code
↓
If syntax error → Show error, stop
↓
Execute code line by line
↓
If runtime error → Show error with traceback
↓
Display output in Output tabInput Handling
The input() Function
Python's input() function works inline:
python
age = input("How old are you? ")
print(f"You are {age} years old")When executed:
- "How old are you?" appears in the output
- An input field appears below
- You type your answer and press Enter
- Execution continues with your input
Multiple Inputs
Each input() call waits for you to respond:
python
first = input("First name: ")
last = input("Last name: ")
print(f"Hello, {first} {last}!")Output Display
Normal Output
print() statements appear in green text:
python
print("Hello, World!")
# Output: Hello, World!Error Output
Errors appear in red with details:
python
print(undefined_variable)
# Output: NameError: name 'undefined_variable' is not definedSupported Python Features
What Works
- All basic Python syntax
- Standard library modules (most)
print(),input(),range(),len(), etc.- Lists, dictionaries, sets, tuples
- Functions and classes
- File operations (in-memory)
math,random,datetime,json, etc.
What Doesn't Work
- Network requests (
requests,urllib) - System calls (
os.system(),subprocess) - GUI libraries (
tkinter,pygame) - Some C-extension modules
Loading Additional Packages
Some packages can be loaded on demand:
python
import micropip
await micropip.install('numpy')
import numpy as npINFO
For most assignments, you won't need additional packages.
Performance
Speed
Pyodide runs at near-native speed for most code. You might notice slowness with:
- Very large loops (millions of iterations)
- Heavy computation
- Large data structures
Memory
Browser memory is limited. Avoid:
- Creating huge lists
- Infinite loops
- Loading large files
Clearing Output
Click the Clear button to:
- Erase all code from the editor
- Start fresh
WARNING
Clear removes all your code! Make sure you've saved it elsewhere if needed.
Troubleshooting
"Python interpreter failed to load"
- Check your internet connection
- Refresh the page
- Wait for "Loading Python..." to complete
Code runs forever
If your code has an infinite loop:
- Refresh the page
- Fix the loop condition
- Try again
Output looks wrong
- Check for missing
print()statements - Verify your logic
- Add debug prints to trace execution