Python Lab

A practice space where NAMSSN UI students can learn Python from scratch and use it to explore calculus, sequences and series, random processes, and simple differential equations.

How this lab fits together

Python here is not for building big software projects. It is a thinking partner for mathematics. You type short pieces of code, run them, look at the output, and adjust — like checking examples and exploring patterns by hand, but with a faster pencil.

  • • This page: a live Python pad plus a compact learning path.
  • • Subpages: slower, more detailed explanations for students and tutors.
🌱Absolute beginners welcome 📊Calculus & series support 🎲Randomness & simulations 🧪Mini mathematical experiments

Students who stay patient with the modules and keep using Python on real UI problems will very quickly become comfortable designing their own notebooks and experiments.

Python Lab path
Choose where to start, then come back here to run and test your code.

🌱 Foundations

For students who have never coded before. Slow, gentle introduction: running code, variables, lists, loops, and basic functions.

Best place to start Open foundations

📐 Sequences & integrals

Dedicated to real analysis: sequences, series, and numerical integrals. Use it alongside your analysis and calculus courses.

For analysis courses Open analysis track

🧪 Experiments & projects

Random walks, simple ODEs, and mini projects tied to UI courses and the ODE–Integration Bee. Turn computations into small research-style notes.

For more confidence Open projects

Module 0 • First contact with Python Beginner

Start here if you have never written code before. By the end of this module you should know how to run code, print values, and read error messages without panic.

0.1 Running your first lines

Python executes your code line by line, top to bottom. We use print(...) to see results:

  • print(2 + 3)
  • print(2**5)
  • print("Hello NAMSSN")

Goal: feel comfortable typing a few lines, pressing “Run code”, and reading the output.

0.2 Variables and simple expressions

A variable is just a name attached to a value. You can reuse it many times:

  • n = 5
  • h = 0.01
  • area = 2 * 3.14 * h
See detailed explanation
0.3 When things break (errors)

Errors look scary at first, but they are extremely useful. Python literally tells you what went wrong and where. In this module you intentionally cause and fix a few simple errors.

Study more examples

Goal: Never think “I am bad at coding”. Think “Python is telling me what to fix.”

Module 1 • Core Python for maths Beginner

Here you learn the basic building blocks: numbers, lists, for-loops, and functions. These are the tools you will reuse in every later module.

1.1 Numbers, lists, and the math module

Many experiments start with “take these numbers and compute something for each of them”. Lists are perfect for that:

  • xs = [0, 0.5, 1, 1.5, 2]
  • import math
  • print(math.sin(1), math.exp(1))
More on lists and loops
1.2 Loops and pattern spotting

Loops let you repeat the same action for many values and see patterns quickly:

for n in range(1, 6):
    print(n, n**2)

You will generate small tables that look like what you normally compute by hand.

Step-by-step loops
1.3 Writing your own functions

Functions bundle a mathematical rule into a reusable piece of code:

def f(x):
    return x**2 + 1

You will write functions that mirror formulas from your UI courses.

Full function walkthrough

Module 2 • Sequences, series, and integrals Intermediate

This module connects directly to analysis and series courses. You use Python to generate terms, compute partial sums, and approximate integrals numerically.

2.1 Sequences and limits

You generate terms of a sequence and look at what they seem to approach:

def a(n):
    return (1 + 1/n)**n

for n in [1, 2, 5, 10, 50, 100, 1000]:
    print(n, a(n))
See full sequence track
2.2 Partial sums of a series

Here you build short scripts that compute partial sums and let you “see” convergence or divergence:

def partial_sums(N):
    s = 0.0
    for n in range(1, N+1):
        s += 1/n**2
    return s
Expand to more series
2.3 Approximating integrals (Riemann-style)

You write a simple Riemann-sum style approximation to a definite integral:

import math

def approx_integral(f, a, b, n):
    h = (b - a) / n
    s = 0.0
    for k in range(n):
        x = a + (k + 0.5)*h   # midpoint rule
        s += f(x)
    return s * h
See full integral unit

Goal: Use Python to build intuition alongside the theorems from class.

Module 3 • Randomness, ODEs, and small experiments Advanced

Now you start building genuine experiments: simple random walks, basic ODE solvers, and small data collections. The aim is not “perfect numerics” but good intuition.

3.1 Random walk on the line

You simulate a one-dimensional random walk and print a few sample paths:

Explore random walk theme
3.2 Euler steps for a simple ODE

For a basic ODE like y' = y, you can write a short Euler method and print the approximate values:

Open ODE experiments
3.3 Designing your own mini project

In this final module you are invited to design a small experiment tied to a UI course: series comparison, simple Markov chain, numerical experiment for the ODE–Integration Bee, or anything you are curious about.

See project design patterns
Ambition for this lab: a NAMSSN UI student who completes Modules 0–3 and keeps using Python on real course problems should be able to read, edit, and design their own maths notebooks confidently.

Live Python pad

Loading Python in your browser…

Type Python code and run it directly in the browser. Use this pad to test ideas, check patterns, and support your coursework and problem solving.

Load an example:
Quick inserts
Patterns:
Editor
You can run several lines at once. Use print(...) to see values. For now, plotting is not enabled here, but you can copy code into a notebook later for graphs.
You can copy this code into Colab or a local Jupyter notebook for larger experiments and plots.
Python runs fully in your browser; no account or installation needed.
Output
Run some code and your output will appear here.

How to use this lab effectively

  • • Change at least one line in every example you load and see what happens.
  • • Translate at least one formula per week from your UI courses into a Python function.
  • • When you see a limit, series, or ODE in class, ask: “Can I test this numerically in Python?”
  • • Keep a small notebook (or text file) of experiments you find interesting.

Link with other parts of the hub: you can paste code or results into the Problems hub or write about an experiment in the Student Bulletin.