Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Interactive Pyodide Notebook — Jupyter-Style CodeMirror Version (4 Cells)

🔄 Restart Kernel ⏳ Loading Pyodide…

Cell 1 — Fibonacci Example

def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a

print(‘fib(10) =’, fib(10))

▶ Run Clear

Cell 2 — List Comprehension

nums = [1, 2, 3, 4, 5]

squares = [x**2 for x in nums] print(‘Squares:’, squares) print(‘Sum:’, sum(squares))

▶ Run Clear

Cell 3 — String Operations

text = 'Pyodide runs Python in your browser!' print('Original:', text) print('Upper:', text.upper()) print('Length:', len(text))
▶ Run Clear

Cell 4 — Math Operations

import math

radius = 7 area = math.pi * radius**2 circumference = 2 * math.pi * radius

print(‘Radius:’, radius) print(‘Area:’, round(area, 2)) print(‘Circumference:’, round(circumference, 2))

▶ Run Clear

Exercises

Exercise