Scratchpad for Python ideas
Test a language feature, check an edge case, or prototype a function. The playground uses the same local Python runtime as the full compiler.
Snippets to try
Open a snippet in the compiler, change a value, and run it again. Predicting the output before pressing Run is one of the fastest ways to learn.
Try a few transformations and print the results.
text = " Python Playground "
print(text.strip())
print(text.strip().upper())
print(text.strip().replace(" ", "-"))
print(text.strip()[::-1])Change the condition and watch the output change.
numbers = list(range(1, 16))
squares = [number ** 2 for number in numbers]
odd_squares = [number ** 2 for number in numbers if number % 2 == 1]
print(squares)
print(odd_squares)Use the standard library to measure elapsed time.
import time
start = time.perf_counter()
total = sum(number ** 2 for number in range(1_000_000))
elapsed = time.perf_counter() - start
print("Total:", total)
print(f"Elapsed: {elapsed:.4f} seconds")The playground is the same runtime with a lighter introduction. The full compiler page explains standard input, packages, keyboard shortcuts, and the execution limits in more detail.