Online Python Compiler
Write and run Python code in your browser — perfect for learning, practice, and quick checks.
Python Code Editor
Output
Standard Output (stdout)
Standard Error (stderr)
Execution Info
Exit Code:
Run Status:
Usage Instructions
- Write Python code in the left editor (for example, use
print). - Click Run Code to execute the program online.
- The right panel shows output and errors.
- Green section shows standard output (e.g.,
print). - Red section shows runtime errors and tracebacks.
- Execution info includes the exit code and run status.
- Shortcut:
Ctrl+Enter(Cmd+Enteron Mac).
Python Basics
Basic Structure:
# Simple Hello World
print("Hello, Python!")
print("Hello, Python!")
Common Built-in Types:
int/float- Numbersstr/bool- Strings and Booleanslist/tuple- Sequencesdict/set- Mappings and Sets
Control Flow
Conditions and Loops:
n = 5
if n % 2 == 0:
print("even")
else:
print("odd")
for i in range(3):
print(i)
if n % 2 == 0:
print("even")
else:
print("odd")
for i in range(3):
print(i)
Functions and Modules
Function Example:
def add(a, b):
return a + b
if __name__ == "__main__":
print(add(2, 3))
return a + b
if __name__ == "__main__":
print(add(2, 3))
FAQ
Which Python versions are supported?
Generally, popular Python 3 versions are supported; exact versions depend on the backend environment.
Can I install third‑party packages?
The environment is sandboxed and does not support installing external dependencies online. Prefer examples that use only the standard library.
Is there a time limit for execution?
Yes. To prevent infinite loops and ensure fair use, execution has a time limit and will auto‑terminate on timeout.
Can I save my code?
Saving online is not supported yet. Copy important code locally, or store snippets using bookmarks/notes.
Is interactive input supported?
Interactive input (e.g., input()) is not supported. For testing, hardcode your test data or use fixed values.
Sample Programs (run with the button above)
1. Recursive Factorial
def factorial(n):
return 1 if n <= 1 else n * factorial(n - 1)
if __name__ == "__main__":
print("5! =", factorial(5))
return 1 if n <= 1 else n * factorial(n - 1)
if __name__ == "__main__":
print("5! =", factorial(5))
2. List Maximum
nums = [3, 7, 1, 9, 4]
max_val = nums[0]
for x in nums[1:]:
if x > max_val:
max_val = x
print("Maximum:", max_val)
max_val = nums[0]
for x in nums[1:]:
if x > max_val:
max_val = x
print("Maximum:", max_val)