scipy
ScienceScientific computing
What is scipy?
SciPy builds on NumPy to provide a large collection of algorithms for scientific and technical computing. It includes modules for optimization, linear algebra, integration, interpolation, signal processing, statistics, and more. SciPy is used by physicists, engineers, and data scientists who need precise numerical methods beyond basic array math.
PyRun includes SciPy as a bundled Pyodide package. You can use scipy.optimize, scipy.stats, scipy.interpolate, and other submodules directly in your browser — no local installation required. It's an ideal environment for testing numerical algorithms or exploring scientific methods interactively.
Code Example
Numerical root finding and descriptive statistics.
from scipy import optimize, stats
import numpy as np
# Root finding
def f(x):
return x**3 - 2*x - 5
result = optimize.root_scalar(f, bracket=[2, 3], method='brentq')
print("Root of f(x) = x³ - 2x - 5:")
print(f" x = {result.root:.6f} (converged: {result.converged})")
# Basic statistics
data = np.array([2.1, 2.5, 3.0, 3.2, 3.8, 4.0, 4.5, 5.1])
print("\nDescriptive stats:")
print(f" mean = {np.mean(data):.3f}")
print(f" median = {np.median(data):.3f}")
print(f" stdev = {np.std(data):.3f}")
t_stat, p_val = stats.ttest_1samp(data, popmean=3.5)
print(f"\nOne-sample t-test (μ=3.5): t={t_stat:.4f}, p={p_val:.4f}")Why run scipy in PyRun?
- ✦ Zero setup — no pip install, no virtual environment, no Python download
- ✦ Instant results — powered by WebAssembly, runs locally in your browser
- ✦ Share your code — generate a link and anyone can run it instantly
- ✦ Works offline — after first load, PyRun runs without internet
Related Packages
Recommended Python Resources
Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.
Python Loops
Learn how to use Python loops to iterate over data. Master for loops, while loops, break, continue, and loop best practices with interactive examples.
How to Sort a List in Python
Learn how to sort a list in Python using the sort() method and the sorted() function. Discover custom key sorting and reverse order examples.
Python String Methods
A complete reference guide for Python string manipulation. Master formatting, searching, splitting, replacing, and checking string properties.
Python vs JavaScript: Which Programming Language is Best?
A comprehensive comparison between Python and JavaScript. Explore syntax differences, performance, use cases (backend vs frontend), and coding examples.