← Back to all projects

LEARN HIGH SCHOOL MATH WITH PYTHON

High school math is often taught as a series of abstract rules to memorize for a test. Move $x$ to the other side, SOH CAH TOA, Finding the vertex.

Learn High School Math with Python: From Algebra to Calculus

Goal: Deeply understand the mathematical foundations of high school curriculum—Algebra, Geometry, Trigonometry, Statistics, and Calculus—by building software that solves, visualizes, and simulates these concepts. You will move from “memorizing formulas” to “modeling the world.”


Why Math with Python Matters

High school math is often taught as a series of abstract rules to memorize for a test. “Move $x$ to the other side,” “SOH CAH TOA,” “Finding the vertex.”

When you combine Math with Python, you unlock:

  1. Visualization: Seeing the geometry behind the algebra instantly.
  2. Simulation: Testing probability theories with millions of trials instead of flipping a coin 10 times.
  3. Application: Using matrices not just to solve simultaneous equations, but to rotate 3D objects in a video game.
  4. Automation: Building tools that solve the tedious parts of math so you can focus on the logic.

In the real world, math is the engine of technology. Python is the steering wheel.


Core Concept Analysis

1. The Variable: Math vs. Computer Science

In Math, $x$ is an unknown to be solved. In Python, x is a bucket storing a value. Bridging this gap is the first step.

Math:  x + 5 = 10  (x is a specific unknown value)
Python: x = 5      (x is a location in memory holding 5)
        y = x + 5  (y becomes 10)

To solve equations in Python like you do in Math, we often use Symbolic Math (SymPy) or Numerical Methods.

2. The Function: Mapping Inputs to Outputs

The core concept of Pre-Calculus is the function $f(x)$.

      Input (x)        Function f(x)        Output (y)
    ┌───────────┐    ┌───────────────┐    ┌───────────┐
    │     3     │───▶│   x^2 + 1     │───▶│    10     │
    └───────────┘    └───────────────┘    └───────────┘

In Python:

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

Understanding domain (valid inputs) and range (possible outputs) corresponds to type checking and error handling in programming.

3. The Cartesian Plane (Coordinate Geometry)

Every pixel on your screen is a coordinate in a 2D plane.

       +Y
        │
  (-x,y)│ (x,y)
        │
───(-x)─┼──(+x)─── +X
        │
 (-x,-y)│ (x,-y)
        │
       -Y

Building games or plotting data requires mastering the $(x, y)$ coordinate system, distance formulas, and vectors.

4. Trigonometry: The Mathematics of Cycles

Trigonometry isn’t just about triangles; it’s about things that repeat (circles, waves, sound).

      /|
     / |
  r /  | y    sin(θ) = y/r
   / θ |      cos(θ) = x/r
  /____|
     x

In Python, math.sin() and math.cos() are the foundations of animation, audio synthesis, and rotational physics.

5. Statistics & Probability: The Law of Large Numbers

Math class says “The probability is 50%.” Python lets you prove it.

Simulation:
1. Flip coin
2. Record result
3. Repeat 1,000,000 times
4. Count heads / total

This is the Monte Carlo method, a powerful tool used in finance and science that high school math rarely touches upon.


Concept Summary Table

Concept Cluster What You Need to Internalize
Algebra & Logic Variables are containers. Equations are relationships. Algorithms are step-by-step proofs.
Geometry & Graphics Shapes are defined by coordinates. Transformations (scaling, rotation) are math operations on those coordinates.
Functions & Modeling Code functions def f(x) map directly to mathematical functions $f(x)$. They model real-world behaviors.
Trigonometry Sine and Cosine convert angles (polar) to coordinates (Cartesian). They describe oscillation and rotation.
Calculus (Change) Derivatives are “instantaneous speed” (slope). Integrals are “accumulation” (area). Computers approximate these with loops.
Statistics The world is messy. We use data distributions and large simulations to find the truth hidden in noise.

Deep Dive Reading by Concept

This section maps high school math topics to resources that explain them through a computational lens.

Algebra & Pre-Calculus

Concept Resource
Variables & Loops “Doing Math with Python” by Amit Saha — Ch. 1: “Working with Numbers”
Graphing Data “Doing Math with Python” by Amit Saha — Ch. 2: “Visualizing Data with Graphs”
Solving Equations SymPy Documentation — “Solvers” tutorial

Geometry & Trigonometry

Concept Resource
Fractals & Coordinates “Doing Math with Python” by Amit Saha — Ch. 6: “Drawing Geometric Shapes and Fractals”
Trig in Games “Program Arcade Games” by Paul Vincent Craven — Ch. 11: “Graphics and Trig”

Calculus & Statistics

Concept Resource
Calculus “Doing Math with Python” by Amit Saha — Ch. 7: “Solving Calculus Problems”
Probability “Think Stats” by Allen B. Downey — Ch. 1: “Exploratory Data Analysis”

Project List

We will progress from basic Algebra to advanced Calculus and Statistics.


Project 1: The “Homework Destroyer” (Equation Solver)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: JavaScript (Node.js), Julia
  • Coolness Level: Level 2: Practical but Forgettable (but useful!)
  • Business Potential: 2. The “Micro-SaaS” (Homework help apps are huge)
  • Difficulty: Level 1: Beginner
  • Knowledge Area: Algebra / Parsing
  • Software or Tool: Python Standard Library + (Optional) SymPy
  • Main Book: “Doing Math with Python” by Amit Saha

What you’ll build: A Command Line Interface (CLI) tool that takes a string input like 2x + 5 = 15 or x^2 + 5x + 6 = 0 and outputs the value(s) of $x$, showing the steps if possible.

Why it teaches Algebra: You have to teach the computer how to “balance” an equation. You will write logic to isolate $x$, which forces you to strictly understand the order of operations and inverse operations.

Core challenges you’ll face:

  • Parsing Input: Breaking 2x + 5 into coefficients and constants. (Maps to Algebraic Structure)
  • Inverse Operations: To solve + 5, you must subtract 5. (Maps to Balancing Equations)
  • The Quadratic Formula: Implementing $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ without crashing on negative roots. (Maps to Complex Numbers)

Key Concepts

  • Operator Precedence: “Python Crash Course” - Basic Math section
  • String Manipulation: “Automate the Boring Stuff with Python” - Ch. 6

Difficulty: Beginner Time estimate: Weekend Prerequisites: Basic Python syntax (variables, if/else, basic math operators)


Real World Outcome

You’ll have a script that solves your math homework.

Example Output:

$ python solver.py
Enter equation: 3x - 9 = 0
> Detected Linear Equation
> Step 1: Add 9 to both sides -> 3x = 9
> Step 2: Divide by 3 -> x = 3

Enter equation: x^2 - 5x + 6 = 0
> Detected Quadratic Equation
> Coefficients: a=1, b=-5, c=6
> Discriminant: 1 (Real solutions)
> Solution 1: x = 3.0
> Solution 2: x = 2.0

The Core Question You’re Answering

“What is an algorithm?”

Before you write code, realize that Algebra is just a manual algorithm you execute on paper. You are translating that manual process into a digital one.

Concepts You Must Understand First

  1. Linear Equations
    • How do you isolate a variable?
    • What is a coefficient vs a constant?
  2. Quadratic Equations
    • What is the standard form $ax^2 + bx + c = 0$?
    • What does the discriminant tell you about the roots?

Questions to Guide Your Design

  1. Input Handling
    • How will you handle spaces? 2x+5=0 vs 2x + 5 = 0?
    • How do you split the Left Hand Side (LHS) from the Right Hand Side (RHS)?
  2. Logic
    • How do you detect if it’s linear (power 1) or quadratic (power 2)?
    • What happens if the discriminant is negative? (Crash or show complex numbers?)

Thinking Exercise

Parsing the Equation

Before coding, trace how you read an equation: 3x + 7 = 22

  1. Identify the = sign.
  2. Left side: 3x + 7
  3. Right side: 22
  4. Identify the term with x: 3x.
  5. Identify the loose number: +7.
  6. Move +7 to the right (become -7). 22 - 7 = 15.
  7. Divide by 3. 15 / 3 = 5.

Can you write a regex or string split to do steps 1-3?

The Interview Questions They’ll Ask

  1. “How would you handle an equation with parentheses like 3(x - 2) = 15?” (Requires distribution logic)
  2. “What is the time complexity of solving a quadratic equation?” (O(1) - it’s a formula)
  3. “How do you handle floating point precision errors in Python when calculating roots?”

Hints in Layers

Hint 1: Start Simple Don’t try to parse everything. Assume the user always types ax + b = c. Split by spaces.

Hint 2: String Splitting Use input_string.split('=') to separate sides.

Hint 3: Coefficients If you have 3x, you can replace x with empty string to get 3. careful with -x (coefficient is -1).

Hint 4: Complex Numbers Python has built-in complex number support. cmath.sqrt(-1) works where math.sqrt(-1) crashes.

Books That Will Help

Topic Book Chapter
String Manipulation “Automate the Boring Stuff” Ch. 6
Quadratic Formula “Doing Math with Python” Ch. 1

Project 2: The Visual Graphing Calculator

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: JavaScript (Canvas API), C# (Unity)
  • Coolness Level: Level 2: Practical
  • Business Potential: 2. Micro-SaaS (Web-based grapher)
  • Difficulty: Level 1: Beginner/Intermediate
  • Knowledge Area: Functions / Coordinate Geometry
  • Software or Tool: matplotlib or turtle
  • Main Book: “Doing Math with Python” - Amit Saha

What you’ll build: A desktop application (using matplotlib) that plots any function $y = f(x)$. It should draw the X and Y axes, grid lines, and plot the curve of linear, quadratic, cubic, and trigonometric functions.

Why it teaches Functions: You visualize the relationship between input $x$ and output $y$. You see how changing $m$ in $y=mx+b$ tilts the line, or how $a$ in $y=ax^2$ makes the parabola skinny or fat.

Core challenges you’ll face:

  • Domain Generation: Creating a list of x-values (e.g., from -10 to 10 with step 0.1). (Maps to Domain & Range)
  • Vectorization: Calculating y for every x efficiently. (Maps to Function Mapping)
  • Handling Asymptotes: What happens when you plot $y = 1/x$ at $x=0$? (Maps to Limits & Continuity)

Key Concepts

  • Lists & Loops: Python Basics
  • Plotting Libraries: matplotlib.pyplot basics

Difficulty: Beginner Time estimate: Weekend Prerequisites: Lists, For-loops, installing libraries (pip install matplotlib)


Real World Outcome

You generate professional-grade mathematical plots.

Example Output:

# (Visual window opens showing a Parabola and a Sine wave)
# You see the axes crossing at (0,0)
# You see the grid
# You see the legend "y = x^2"

The Core Question You’re Answering

“What does a function look like?”

Functions describe shapes. This project turns abstract algebra ($y=x^2$) into concrete geometry (a U-shape).

Concepts You Must Understand First

  1. Cartesian Coordinates
    • How do you plot a point $(x, y)$?
  2. Domain and Range
    • Why do we need a “step” size? Why can’t we plot every number? (Continuous vs Discrete)

Questions to Guide Your Design

  1. Data Structure
    • How do you store the points? Two lists? x_values = [], y_values = []?
  2. Resolution
    • If your step is 1, a circle looks like a hexagon. If your step is 0.0001, your computer gets slow. How do you choose?

Thinking Exercise

The Loop

Write the loop on paper for plotting $y = 2x + 1$ from $x=0$ to $x=3$.

  1. x=0 -> y = 2(0)+1 = 1 -> Point(0, 1)
  2. x=1 -> y = 2(1)+1 = 3 -> Point(1, 3)
  3. x=2 -> y = 2(2)+1 = 5 -> Point(2, 5)
  4. x=3 -> y = 2(3)+1 = 7 -> Point(3, 7)

Now, how do you do this with a step of 0.1?

The Interview Questions They’ll Ask

  1. “How do you define the resolution of a graph?”
  2. “Explain the difference between discrete data points and a continuous line plot.”
  3. “How would you handle a division by zero error when plotting $y=1/x$?”

Hints in Layers

Hint 1: Creating the Domain Use range() for integers. For decimals, you’ll need a while loop or numpy.linspace().

Hint 2: Calculating the Range Use a list comprehension: y_values = [x**2 for x in x_values].

Hint 3: Plotting plt.plot(x_values, y_values) connects the dots for you.

Hint 4: Axes By default, matplotlib might not center the axes. Look up spines in matplotlib to move axes to the center (0,0).

Books That Will Help

Topic Book Chapter
Visualizing Data “Doing Math with Python” Ch. 2
Arrays (Numpy) “Python for Data Analysis” Ch. 4

Project 3: The Ballistics Computer (Trigonometry Simulator)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: Lua (Love2D), C++
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. Resume Gold (Game Physics)
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Trigonometry / Physics
  • Software or Tool: Python Standard Library or pygame
  • Main Book: “Program Arcade Games” by Paul Vincent Craven

What you’ll build: A simulation of a cannonball being fired. You input the angle (in degrees) and velocity. The program calculates the trajectory using Sine and Cosine, updates the position frame-by-frame, and tells you where it lands and max height.

Why it teaches Trigonometry: You learn what Sine and Cosine actually do: they split a diagonal force into horizontal (x) and vertical (y) components. You also encounter gravity as a constant acceleration.

Core challenges you’ll face:

  • Decomposing Vectors: Converting Speed + Angle into Velocity_X and Velocity_Y. (Maps to SOH CAH TOA)
  • Radians vs Degrees: Python’s math.sin takes radians, humans think in degrees. (Maps to Unit Circle)
  • Time Stepping: Updating position based on velocity: $x_{new} = x_{old} + v_x \cdot dt$. (Maps to Kinematics)

Key Concepts

  • Trigonometric Functions: math.sin, math.cos, math.radians
  • Physics loops: The “Game Loop” concept

Difficulty: Intermediate Time estimate: Weekend Prerequisites: Understanding of variables and loops. Basic physics helps.


Real World Outcome

You simulate the physics engine used in Angry Birds.

Example Output:

Input Angle (deg): 45
Input Speed (m/s): 100

Time: 0.0s | X: 0.00m | Y: 0.00m
Time: 1.0s | X: 70.71m | Y: 65.81m
Time: 2.0s | X: 141.42m | Y: 121.62m
...
Impact!
Total Distance: 1019.3m
Max Height: 254.8m

The Core Question You’re Answering

“Why do we need SOH CAH TOA?”

Because the world moves in curves and diagonals, but computers (and coordinate systems) only understand grids (Up/Down, Left/Right). Trig is the translator.

Concepts You Must Understand First

  1. Vector Components
    • Why is $V_x = V \cdot \cos(\theta)$?
    • Why is $V_y = V \cdot \sin(\theta)$?
  2. Gravity
    • How does gravity affect only the vertical velocity? ($V_y$ changes, $V_x$ stays constant… usually).

Questions to Guide Your Design

  1. Unit Conversion
    • How do you convert 45 degrees to radians? ($\text{deg} \cdot \frac{\pi}{180}$)
  2. The Loop
    • How often do you update the position? Every second? Every 0.1s? (This is dt or Delta Time).
  3. Stopping Condition
    • When do you stop the loop? When $y < 0$ (hits the ground).

Thinking Exercise

Trace a Projectile

At $t=0$, ball is at $(0,0)$. $V_x = 10$, $V_y = 10$. Gravity $g = -1$.

Step 1 ($t=1$):

  • $x = 0 + 10 = 10$
  • $y = 0 + 10 = 10$
  • $V_y$ becomes $10 - 1 = 9$

Step 2 ($t=2$):

  • $x = 10 + 10 = 20$
  • $y = 10 + 9 = 19$ (Notice it went up less)
  • $V_y$ becomes $9 - 1 = 8$

Code this loop.

The Interview Questions They’ll Ask

  1. “Why do game engines use delta time (dt) in physics calculations?”
  2. “What happens if you use degrees in math.sin() directly?”
  3. “How would you add wind resistance?” (Hint: It reduces velocity based on speed).

Hints in Layers

Hint 1: The Import import math

Hint 2: The Conversion angle_rad = math.radians(angle_deg)

Hint 3: The Components vx = speed * math.cos(angle_rad) vy = speed * math.sin(angle_rad)

Hint 4: Gravity Inside your while y >= 0: loop, subtract gravity from vy after you update position. vy -= 9.8 * dt.

Books That Will Help

Topic Book Chapter
Trig & Vectors “Program Arcade Games” Ch. 11
Physics Simulation “Nature of Code” (Processing/JS based but concepts apply) Ch. 1

Project 4: The Chaos Game (Fractals & Complex Numbers)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C (for speed), GLSL (Shader)
  • Coolness Level: Level 5: Pure Magic
  • Business Potential: 1. Resume Gold (Shows algorithm optimization)
  • Difficulty: Level 3: Advanced HS / Early College
  • Knowledge Area: Complex Numbers / Iterative Functions
  • Software or Tool: PIL (Pillow) or matplotlib
  • Main Book: “Doing Math with Python” - Amit Saha

What you’ll build: A program that generates the Mandelbrot Set. You will iterate a function $z_{n+1} = z_n^2 + c$ using complex numbers and visualize which points remain stable vs which ones fly off to infinity.

Why it teaches Complex Numbers: You learn that complex numbers ($a + bi$) aren’t just abstract nonsense; they are points on a 2D plane. You see how simple multiplication of these numbers creates infinite beauty.

Core challenges you’ll face:

  • Complex Arithmetic: Squaring a complex number. (Maps to i squared is -1)
  • Escape Time Algorithm: Determining if a number grows too large. (Maps to Sequences & Series)
  • Coordinate Mapping: Converting pixel $(x,y)$ to complex plane coordinate $(r, i)$.

Key Concepts

  • Complex Plane: Real axis vs Imaginary axis
  • Absolute Value (Magnitude): Distance from zero $\sqrt{a^2 + b^2}$

Difficulty: Intermediate/Advanced Time estimate: 1 Week Prerequisites: Understanding Functions, Loops, and Coordinate Systems.


Real World Outcome

You generate one of the most famous images in mathematics history from scratch.

Example Output: An image file mandelbrot.png showing the black beetle shape surrounded by colorful spirals.

The Core Question You’re Answering

“What happens when you feedback the output of a function into its input?”

This is chaos theory. A simple rule ($z^2 + c$), repeated infinitely, produces infinite complexity.

Concepts You Must Understand First

  1. Complex Numbers
    • What is $i$?
    • How do you add and multiply complex numbers?
  2. The Complex Plane
    • The x-axis is Real. The y-axis is Imaginary.

Questions to Guide Your Design

  1. The Grid
    • You are drawing an image of 800x600 pixels.
    • The Mandelbrot set lives mostly between x = -2 and x = 1, y = -1 and y = 1.
    • How do you map pixel(0,0) to complex(-2, -1)?
  2. The Loop
    • For every pixel, you run a loop (max 100 times). If the number gets huge, it’s NOT in the set. If it stays small, it IS in the set.

Thinking Exercise

Iterating Numbers

Take $c = 1$. Start $z = 0$.

  1. $z = 0^2 + 1 = 1$
  2. $z = 1^2 + 1 = 2$
  3. $z = 2^2 + 1 = 5$
  4. $z = 5^2 + 1 = 26$ -> Explodes to infinity. (Not in set)

Take $c = -1$. Start $z = 0$.

  1. $z = 0^2 + (-1) = -1$
  2. $z = (-1)^2 + (-1) = 0$
  3. $z = 0^2 + (-1) = -1$ -> Oscillates. (Stays small -> In set)

Now code this check for any c.

The Interview Questions They’ll Ask

  1. “What is the difference between CPU and GPU for this kind of task?” (Parallelism)
  2. “How do you color the image based on ‘escape time’?”
  3. “What is the magnitude of a complex number?”

Hints in Layers

Hint 1: Python’s Complex Type Python supports c = complex(real, imag). z = z**2 + c just works!

Hint 2: The Loop Structure

for y in range(height):
    for x in range(width):
        # convert x,y to c
        # run iteration loop
        # set pixel color

Hint 3: Optimization The condition abs(z) > 2 is enough to know it escapes. abs(z) involves a square root (slow). Use z.real**2 + z.imag**2 > 4 instead.

Books That Will Help

Topic Book Chapter
Fractals “Doing Math with Python” Ch. 6
Complex Numbers “Python Standard Library Docs” cmath module

Project 5: The Monte Carlo Casino (Probability Simulator)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: R, Excel VBA
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 3. Service & Support (Risk Analysis)
  • Difficulty: Level 1: Beginner
  • Knowledge Area: Probability / Statistics
  • Software or Tool: Python random module
  • Main Book: “Think Stats” by Allen B. Downey

What you’ll build: A simulation that plays 1,000,000 games of a simple chance game (like rolling dice or drawing cards) to experimentally determine the probability of winning, rather than using formulas.

Why it teaches Probability: High school teaches $P(A) = \frac{\text{Desired}}{\text{Total}}$. This is “Theoretical Probability.” This project teaches “Empirical Probability.” You learn that in the short term, anything happens (variance), but in the long term, the math always wins (Law of Large Numbers).

Core challenges you’ll face:

  • Randomness: Generating true random numbers (or pseudo-random). (Maps to Stochastic Processes)
  • Tracking State: Counting wins/losses over huge loops.
  • Convergence: Observing how the % settles down as $N$ increases.

Key Concepts

  • Law of Large Numbers: As $N \to \infty$, experimental probability $\to$ theoretical probability.
  • Gambler’s Fallacy: Previous flips do not affect the next flip.

Difficulty: Beginner Time estimate: Weekend Prerequisites: Loops, Random numbers.


Real World Outcome

You can prove to your friends why gambling strategies usually fail.

Example Output:

Simulating 10 coin flips...
Heads: 70.0% (Small sample size error!)

Simulating 1,000 coin flips...
Heads: 51.2%

Simulating 1,000,000 coin flips...
Heads: 50.01% (Math works!)

The Core Question You’re Answering

“Is the game rigged, or is it just variance?”

You learn to distinguish between bad luck (short term) and bad odds (long term).

Concepts You Must Understand First

  1. Independent Events
    • If I flip Heads, is the next flip more likely to be Tails? (No).
  2. Sample Space
    • What are all possible outcomes of rolling two dice? (2 through 12).

Questions to Guide Your Design

  1. The Game
    • Choose a specific game. “Roll two dice. If sum is 7 or 11, Win. Else, Lose.”
  2. Data Collection
    • Do you store every result in a list? (Memory heavy for 1M items). Or just increment a win_count variable? (Efficient).

Thinking Exercise

Theoretical vs Experimental

Game: Roll 1 die. Win if 6. Theoretical Chance: $1/6 \approx 16.66\%$.

Run code: Roll 1: 4 (Lose) -> 0% Win rate. Roll 2: 6 (Win) -> 50% Win rate. Roll 3: 2 (Lose) -> 33% Win rate.

Notice how wild the percentage is early on?

The Interview Questions They’ll Ask

  1. “How do you generate a random number in Python?”
  2. “What is a seed in a random number generator?”
  3. “How would you simulate a biased coin (60% heads)?”

Hints in Layers

Hint 1: Rolling Dice die1 = random.randint(1, 6)

Hint 2: Biased Coin if random.random() < 0.6: return "Heads"

Hint 3: Efficiency Don’t print inside the loop of 1,000,000. It will take forever. Print only the final result.

Books That Will Help

Topic Book Chapter
Probability “Think Stats” Ch. 2
Randomness “Python Standard Library Docs” random module

Project 6: The Secret Message Encoder (Matrix Algebra)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: MATLAB, Julia
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 4. Open Core (Cryptography basics)
  • Difficulty: Level 3: Advanced HS
  • Knowledge Area: Linear Algebra / Matrices
  • Software or Tool: numpy
  • Main Book: “Doing Math with Python” - Amit Saha (or any Linear Algebra text)

What you’ll build: A tool that encrypts text messages using the Hill Cipher. You will convert text to numbers, organize them into vectors, and multiply them by a Key Matrix to scramble them. You’ll then use the Inverse Matrix to decrypt.

Why it teaches Linear Algebra: Most students ask “Why do I need to multiply matrices?” This is why. Matrix multiplication mixes information irreversibly unless you have the key (inverse).

Core challenges you’ll face:

  • Text to Vector: Converting “HELLO” to [7, 4, 11, 11, 14]. (Maps to Data Representation)
  • Matrix Multiplication: Doing the dot product of rows and columns. (Maps to Linear Transformations)
  • Modular Arithmetic: Ensuring numbers stay within 0-25 (A-Z). (Maps to Number Theory)
  • Inverting Matrices: Calculating the determinant and inverse to decrypt. (Maps to Solving Systems)

Key Concepts

  • Dot Product: The core operation of matrices
  • Identity Matrix: The “1” of matrices
  • Inverse Matrix: The “division” of matrices

Difficulty: Advanced Time estimate: 1-2 Weeks Prerequisites: Matrix Multiplication rules, numpy basics.


Real World Outcome

You send a friend a string of random numbers, and they use your script to read the secret message.

Example Output:

Enter Key Matrix: [[3, 3], [2, 5]]
Enter Message: HELP
Vector: [7, 4], [11, 15]

Encrypting...
[7, 4] . Key = [29, 41] % 26 = [3, 15] -> 'DP'
[11, 15] . Key = ... -> ...

Encrypted: DP...
Decrypting using Inverse Key...
Original: HELP

The Core Question You’re Answering

“How do we scramble data so it can be unscrambled?”

Multiplication is easy. Factoring (reversing it) is hard. This is the basis of all modern cryptography.

Concepts You Must Understand First

  1. Matrix Dimensions
    • Can you multiply a 2x2 matrix by a 2x1 vector? (Yes).
    • Can you multiply a 2x2 by a 3x1? (No).
  2. Determinant
    • If the determinant is 0, the matrix has no inverse. You can’t decrypt!

Questions to Guide Your Design

  1. The Alphabet
    • A=0, B=1, … Z=25. Space=26? Punctuation?
  2. Padding
    • Hill Cipher works on blocks (pairs). What if the message “HELLO” has 5 letters? You need to add a dummy letter “X” to make it 6.

Thinking Exercise

Hand Calculation

Key: $\begin{bmatrix} 3 & 3 \ 2 & 5 \end{bmatrix}$ Message “HE” -> H=7, E=4 -> Vector $\begin{bmatrix} 7 \ 4 \end{bmatrix}$

Multiply: Top: $3(7) + 3(4) = 21 + 12 = 33$. Mod 26 = 7 (H) Bottom: $2(7) + 5(4) = 14 + 20 = 34$. Mod 26 = 8 (I)

Encrypted: “HI”

Wait, did we just get lucky that H stayed H?

The Interview Questions They’ll Ask

  1. “What does it mean for a matrix to be singular?”
  2. “Why do we use modulo arithmetic in cryptography?”
  3. “How is matrix multiplication implemented efficiently in hardware?”

Hints in Layers

Hint 1: Use Numpy import numpy as np. np.dot(matrix, vector) does the multiplication.

Hint 2: Modulo result = np.dot(key, vector) % 26

Hint 3: Finding Inverse Mod 26 Standard np.linalg.inv() gives floats. You need the “Modular Multiplicative Inverse” for integers. This is the hardest part. You might want to implement a brute force search for the inverse since the alphabet is small (26).

Books That Will Help

Topic Book Chapter
Matrices “Doing Math with Python” (Use external Linear Algebra resource)
Cryptography “Cracking Codes with Python” Ch. 14 (Affine Cipher)

Project 7: The Derivative Explorer (Calculus Visualization)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: JavaScript (D3.js)
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 2. Micro-SaaS (EdTech tool)
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Calculus I (Differentiation)
  • Software or Tool: matplotlib
  • Main Book: “Doing Math with Python” - Amit Saha

What you’ll build: A tool that takes a function (like $y = x^2$) and plots both the function AND its derivative (rate of change) on the same graph by calculating the slope between tiny points ($dx$).

Why it teaches Calculus: You learn that a derivative isn’t a magic formula you memorized ($2x$); it’s literally just $\frac{rise}{run}$ calculated over a very tiny distance.

Core challenges you’ll face:

  • Numerical Differentiation: Calculating $\frac{f(x+h) - f(x)}{h}$ where $h$ is small. (Maps to Definition of Derivative)
  • Noise: If $h$ is too small, floating point errors make the derivative jagged. (Maps to Limits)
  • Tangent Lines: Drawing the line that touches the curve at one point.

Key Concepts

  • Slope: Rise over Run
  • Limit: What happens as $h \to 0$
  • Tangent Line: The direction the function is going right now

Difficulty: Intermediate Time estimate: Weekend Prerequisites: Functions, Plotting.


Real World Outcome

You visualize “Instantaneous Rate of Change” without using symbolic rules.

Example Output: Plot 1: A Sine Wave ($y = \sin(x)$) Plot 2: A Cosine Wave ($y = \cos(x)$) generated purely by calculating slopes of Plot 1. You just proved the derivative of Sine is Cosine numerically!

The Core Question You’re Answering

“How can we calculate speed at a single instant if speed requires distance/time?”

We cheat. We take a microscopic amount of time.

Concepts You Must Understand First

  1. Slope Formula
    • $m = \frac{y_2 - y_1}{x_2 - x_1}$
  2. The Difference Quotient
    • $\frac{f(x+h) - f(x)}{h}$

Questions to Guide Your Design

  1. Choosing h
    • Try $h = 0.1$. Then $h = 0.0001$. What changes in the graph?
  2. Edge Cases
    • How do you calculate the derivative at the very last point of your list? (You can’t do $x+h$, maybe look back with $x-h$?)

Thinking Exercise

Manual Slope

$f(x) = x^2$. Point at $x=3$. Real derivative: $2x \to 2(3) = 6$.

Approximate with $h=1$: $f(3) = 9$. $f(4) = 16$. Slope = $(16-9) / (4-3) = 7$. (Close to 6).

Approximate with $h=0.1$: $f(3) = 9$. $f(3.1) = 9.61$. Slope = $(9.61 - 9) / 0.1 = 0.61 / 0.1 = 6.1$. (Closer!)

Code this logic.

The Interview Questions They’ll Ask

  1. “What is the difference between symbolic differentiation (SymPy) and numerical differentiation?”
  2. “Why is numerical differentiation unstable for noisy data?”
  3. “What is the central difference theorem?” (Using $x+h$ and $x-h$ is more accurate).

Hints in Layers

Hint 1: Two Lists y_values stores the function. derivative_values stores the calculated slopes.

Hint 2: The Loop Iterate from i = 0 to len(x) - 1. slope = (y[i+1] - y[i]) / (x[i+1] - x[i])

Hint 3: Plotting plt.plot(x, y, label="Function") plt.plot(x[:-1], derivatives, label="Derivative") (Note: derivative list is 1 shorter).

Books That Will Help

Topic Book Chapter
Calculus “Doing Math with Python” Ch. 7

Project 8: The Area Estimator (Integral Calculus)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C++
  • Coolness Level: Level 2: Practical
  • Business Potential: 2. Pro Tool (Scientific Data Analysis)
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Calculus II (Integration)
  • Software or Tool: Python Standard Library
  • Main Book: “Doing Math with Python” - Amit Saha

What you’ll build: A tool that estimates the area under a curve (integral) using Riemann Sums. You will draw rectangles under the graph, sum up their areas, and see how the result approaches the true integral as the rectangles get thinner.

Why it teaches Calculus: Integration is just fancy addition. It’s adding up millions of tiny slices. This project makes that literal.

Core challenges you’ll face:

  • Rectangle Methods: Left endpoint vs Right endpoint vs Midpoint rule.
  • Accuracy vs Speed: Millions of rectangles take time.
  • Visualizing: Drawing the rectangles using matplotlib.bar.

Key Concepts

  • Area under curve: Total accumulation (Distance travelled, Total work done)
  • Riemann Sum: $\sum f(x) \cdot \Delta x$

Difficulty: Intermediate Time estimate: Weekend Prerequisites: Loops, Functions.


Real World Outcome

You understand how physics engines calculate “Total Distance” from variable speed.

Example Output:

Function: y = 2x
Interval: [0, 4]
True Area: 16.0 (Triangle 1/2 * base * height)

With 4 rectangles: Area = 12.0 (Error 25%)
With 10 rectangles: Area = 15.2 (Error 5%)
With 1000 rectangles: Area = 15.99 (Error 0.06%)

The Core Question You’re Answering

“How do we measure the size of a shape that is curvy?”

We assume it’s made of tiny straight boxes.

Concepts You Must Understand First

  1. Geometry Area
    • Area of rectangle = width * height.
  2. Summation Notation
    • $\sum$ means “Add ‘em up”.

Questions to Guide Your Design

  1. Width
    • Width of each bar = $(\text{End} - \text{Start}) / \text{Count}$.
  2. Height
    • For the Left Rule, height is $f(x)$. For Right Rule, $f(x+\text{width})$.

Thinking Exercise

Add rectangles

$y = x$. Interval 0 to 2. Use 2 rectangles. Width = 1.

Left Rule: Rect 1 (at x=0): Height 0. Area = 1 * 0 = 0. Rect 2 (at x=1): Height 1. Area = 1 * 1 = 1. Total = 1. (True answer is 2). Bad estimate.

Midpoint Rule: Rect 1 (at x=0.5): Height 0.5. Area = 0.5. Rect 2 (at x=1.5): Height 1.5. Area = 1.5. Total = 2. (Perfect!)

Why was Midpoint perfect for a straight line?

The Interview Questions They’ll Ask

  1. “What is the Trapezoidal Rule?” (Using trapezoids instead of rectangles).
  2. “How do numerical integrators handle infinite domains?”
  3. “Why is integration often harder than differentiation?”

Hints in Layers

Hint 1: The Width dx = (b - a) / n

Hint 2: The Loop

total_area = 0
for i in range(n):
    x = a + i * dx
    area = f(x) * dx
    total_area += area

Hint 3: Visualization Use plt.bar(x_coords, y_coords, width=dx, align='edge') to show what you calculated.

Books That Will Help

Topic Book Chapter
Integration “Doing Math with Python” Ch. 7

Project 9: The Data Detective (Linear Regression from Scratch)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: R, Julia
  • Coolness Level: Level 2: Practical
  • Business Potential: 5. Industry Disruptor (Data Science Base)
  • Difficulty: Level 3: Advanced HS
  • Knowledge Area: Statistics / Optimization
  • Software or Tool: Python (No Scikit-Learn allowed!)
  • Main Book: “Think Stats” by Allen B. Downey

What you’ll build: A program that takes a messy dataset (e.g., “Hours Studied” vs “Test Score”) and finds the perfect line of best fit ($y = mx + b$) by minimizing the error squared (Least Squares Method) manually.

Why it teaches Statistics: You learn that “correlation” isn’t a vague feeling; it’s a calculable number. You will understand “Error” (Residuals) and how minimizing it drives Machine Learning.

Core challenges you’ll face:

  • Calculating Mean and Variance: The building blocks. (Maps to Descriptive Stats)
  • Covariance: Measuring how two variables move together.
  • Gradient Descent (Optional): Iteratively tweaking $m$ and $b$ to reduce error. (Maps to Optimization)

Key Concepts

  • $R^2$ Value: How “good” is the fit?
  • Residuals: The vertical distance between the point and the line.

Difficulty: Advanced Time estimate: 1 Week Prerequisites: Lists, Loops, Basic Algebra.


Real World Outcome

You build the “Hello World” of Machine Learning.

Example Output:

Reading data.csv...
Found 100 points.

Calculating line of best fit...
Slope (m): 5.2
Intercept (b): 30.1

Equation: Score = 5.2 * (Hours) + 30.1
Prediction: If you study 5 hours, you'll get 56.1.
Error (R^2): 0.85 (Strong correlation)

The Core Question You’re Answering

“How do we predict the future based on the past?”

We assume the pattern continues.

Concepts You Must Understand First

  1. Mean (Average)
    • $\bar{x} = \frac{\sum x}{n}$
  2. Equation of a Line
    • $y = mx + b$. We are looking for the best $m$ and $b$.

Questions to Guide Your Design

  1. The Formula
    • You can use the closed-form math formula: $m = \frac{\sum(x - \bar{x})(y - \bar{y})}{\sum(x - \bar{x})^2}$ Or you can try “Gradient Descent” (hotter topic).
  2. Visualizing
    • Plot the dots (scatter) and the line (plot) on the same graph.

Thinking Exercise

Minimize the Square

Points: (1, 2), (2, 3), (3, 5). Line guess: $y = x$. Preds: 1, 2, 3. Errors: (2-1)=1, (3-2)=1, (5-3)=2. Squared Errors: $1^2 + 1^2 + 2^2 = 6$.

Line guess: $y = 1.5x$. Preds: 1.5, 3, 4.5. Errors: 0.5, 0, 0.5. Squared Errors: $0.25 + 0 + 0.25 = 0.5$. (Much better!)

Code a loop that tries random lines and picks the best one?

The Interview Questions They’ll Ask

  1. “Why do we square the errors instead of just adding them?” (To handle negatives and penalize outliers).
  2. “What is overfitting?”
  3. “How do you implement Linear Regression using Matrix Multiplication?” (Normal Equation).

Hints in Layers

Hint 1: The Lists x_list and y_list.

Hint 2: The Mean x_mean = sum(x_list) / len(x_list)

Hint 3: The Numerator and Denominator Loop through lists: numerator += (x - x_mean) * (y - y_mean) denominator += (x - x_mean)**2 m = numerator / denominator

Books That Will Help

Topic Book Chapter
Correlation “Think Stats” Ch. 7

Project 10: The 3D Renderer (Linear Algebra & Projection)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C (SDL), JavaScript (Three.js internals)
  • Coolness Level: Level 5: Pure Magic
  • Business Potential: 1. Resume Gold (Graphics Programming)
  • Difficulty: Level 4: Expert HS
  • Knowledge Area: Geometry / Matrices
  • Software or Tool: pygame (for drawing lines) + numpy
  • Main Book: “Computer Graphics from Scratch” by Gabriel Gambetta

What you’ll build: A program that defines a 3D cube (8 points with x,y,z) and draws it on a 2D screen. You will implement a Projection Matrix to convert 3D coordinates to 2D, and Rotation Matrices to spin it.

Why it teaches Geometry: You realize that your screen is 2D. 3D is an illusion created by math (Perspective). Distant things look smaller ($x / z$).

Core challenges you’ll face:

  • 3D Coordinates: Storing points as [x, y, z].
  • Projection: Dividing by $z$ to create perspective. $x_{screen} = x / z$.
  • Rotation: Multiplying points by Sine/Cosine matrices to rotate around axes.

Key Concepts

  • Projection: Mapping $R^3 \to R^2$.
  • Matrix Transformation: Rotating points around the origin.

Difficulty: Expert Time estimate: 2 Weeks Prerequisites: Matrices, Trig, Pygame basics.


Real World Outcome

You create a spinning wireframe cube—the basis of every video game ever made.

Example Output: A window opens showing a cube. As you press arrow keys, the cube rotates. It looks 3D because the back lines are smaller than the front lines.

The Core Question You’re Answering

“How do we see depth on a flat screen?”

We scale things down based on how far away they are.

Concepts You Must Understand First

  1. 3D Space
    • Z-axis usually points “into” the screen.
  2. Trig Rotation
    • $x’ = x\cos\theta - y\sin\theta$
    • $y’ = x\sin\theta + y\cos\theta$

Questions to Guide Your Design

  1. The Points
    • A cube has 8 corners. (-1, -1, -1), (1, -1, -1), etc.
  2. The Camera
    • The cube needs to be in front of the camera. If Z=0, you divide by zero. Move the cube to Z=5.

Thinking Exercise

Perspective

Point A: $(2, 2, 2)$. Point B: $(2, 2, 4)$. Point B is twice as far away. It should look half as big. $x_{screen} = x / z$. $A: 2 / 2 = 1$. Screen pos $(1, 1)$. $B: 2 / 4 = 0.5$. Screen pos $(0.5, 0.5)$.

It works!

The Interview Questions They’ll Ask

  1. “What is the Projection Matrix?”
  2. “What is Gimbal Lock?”
  3. “Why do we use 4x4 matrices (Quaternions) in real 3D engines?”

Hints in Layers

Hint 1: Store vertices List of lists: [[x,y,z], ...]

Hint 2: The Project loop For every point: scale = fov / (z + camera_distance) x2d = x * scale + screen_center_x y2d = y * scale + screen_center_y

Hint 3: Connecting lines You need an “edge list” saying “Connect point 0 to point 1”. Don’t just draw dots.

Books That Will Help

Topic Book Chapter
Projection “Computer Graphics from Scratch” Ch. 2

Project 11: The Epidemic Simulator (Exponential Growth)

  • File: LEARN_HIGH_SCHOOL_MATH_WITH_PYTHON.md
  • Main Programming Language: Python
  • Alternative Programming Languages: NetLogo
  • Coolness Level: Level 2: Practical
  • Business Potential: 3. Service (Simulation modeling)
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Functions / Differential Equations
  • Software or Tool: matplotlib or pygame
  • Main Book: “Doing Math with Python”

What you’ll build: A simulation of a virus spreading through a population. You implement the SIR Model (Susceptible, Infected, Recovered). You see how changing the “R-naught” (infection rate) flattens the curve.

Why it teaches Growth: You learn the difference between Linear Growth ($y = mx$) and Exponential Growth ($y = e^x$). You see how small changes in exponents lead to massive outcomes.

Core challenges you’ll face:

  • State Management: Every “person” (dot) has a state (Healthy, Sick, Immune).
  • Collision/Proximity: If Sick touches Healthy -> Healthy becomes Sick.
  • Graphing: Plotting the “Infected Count” over time to see the curve.

Key Concepts

  • Exponential Growth: $N_t = N_0(1+r)^t$
  • Logistics Curve: Growth slows down as people run out.

Difficulty: Intermediate Time estimate: 1 Week Prerequisites: Loops, Distance formula.


Real World Outcome

You understand the math behind “Flatten the Curve.”

Example Output: Animation of green dots (Healthy) moving. Red dots (Sick) appear. Suddenly, the whole screen turns red. Then slowly turns Blue (Recovered). A graph shows a sharp spike vs a slow hill depending on your settings.

The Core Question You’re Answering

“Why did the virus spread so fast?”

Exponential functions grow slowly at first, then explode.

Concepts You Must Understand First

  1. Distance Formula
    • $\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$.
    • Used to check if dots bumped into each other.

Questions to Guide Your Design

  1. Movement
    • Random walk? Or bouncing balls?
  2. Parameters
    • transmission_rate: Probability of getting sick on contact.
    • recovery_time: How long until they turn blue?

Thinking Exercise

Double a penny

Day 1: 1 penny. Day 2: 2. Day 3: 4. … Day 30: $5 million.

Code a loop to verify this.

The Interview Questions They’ll Ask

  1. “What is a differential equation?” (The SIR model uses them).
  2. “How do you optimize collision detection for 1000 particles?” (Quadtrees - advanced).

Hints in Layers

Hint 1: The Class Create a Person class with x, y, status.

Hint 2: The Loop Nested loop: compare every person to every other person. $O(N^2)$. Slow but easy.

Hint 3: Distance Check If dist < 10 and other.status == SICK and self.status == HEALTHY: self.status = SICK.

Books That Will Help

Topic Book Chapter
SIR Model “Doing Math with Python” Ch. 7 (Calculus section mentions growth)

Project Comparison Table

Project Difficulty Time Depth of Understanding Fun Factor
1. Homework Destroyer Beginner Weekend High (Algebra logic) Low (It’s text)
2. Graphing Calc Beginner Weekend Med (Visualizing) Med
3. Ballistics Intermediate Weekend High (Trig usage) High (It’s a game)
4. Chaos Game Advanced 1 Week Deep (Complex numbers) Very High (Art)
5. Monte Carlo Beginner Weekend Med (Probability) Low (Simulation)
6. Secret Encoder Advanced 1-2 Weeks High (Matrices) High (Secret Agent)
7. Derivative Exp. Intermediate Weekend High (Calculus concepts) Med
8. Area Estimator Intermediate Weekend High (Calculus concepts) Med
9. Data Detective Advanced 1 Week High (Real stats) Med
10. 3D Renderer Expert 2 Weeks Deep (Geometry/Linear Alg) Very High
11. Epidemic Sim Intermediate 1 Week Med (Growth models) High

Recommendation

Where to Start?

  • If you hate Math: Start with Project 3 (Ballistics). Seeing things fly and crash makes the math “real” instantly. You’ll accidentally learn Trigonometry.
  • If you love Logic: Start with Project 1 (Equation Solver). It feels like teaching a robot how to think.
  • If you like Art: Start with Project 4 (Chaos Game). The visual feedback is addictive.
  • If you want a Job: Start with Project 9 (Data Detective) or Project 5 (Monte Carlo). These are the foundations of Data Science and Quantitative Finance.

Final Overall Project: The “PyMath” Engine (Build Your Own SymPy)

Goal: Combine everything. Build a library that defines a Variable class, can build Expression trees, differentiate them, simplifiy them, and graph them.

What you’ll build: You won’t use x = 5. You will create x = Variable('x'). You will overload operators so y = x ** 2 + 5 * x creates a tree data structure, not a number. Then you will implement:

  1. .solve(): Finds roots.
  2. .diff(): Returns a new Expression tree representing the derivative ($2x + 5$).
  3. .plot(): Graphs it.

Why this is the Master Project: To build this, you must understand the structure of Algebra (trees), the rules of Calculus (Power rule, Chain rule), and the logic of simplification. You are rebuilding the tool that mathematicians use.

Core Challenges:

  • Object Oriented Programming: Operator overloading (__add__, __mul__).
  • Recursion: Traversing the expression tree to print “2x + 5” or calculate values.
  • Algorithmic Differentiation: Implementing rules like $\frac{d}{dx}(f+g) = f’ + g’$.

Summary

This learning path covers High School Math through 11 hands-on projects.

# Project Name Main Language Difficulty Time Estimate
1 The Homework Destroyer Python Beginner Weekend
2 Visual Graphing Calculator Python Beginner Weekend
3 Ballistics Computer Python Intermediate Weekend
4 The Chaos Game Python Advanced 1 Week
5 Monte Carlo Casino Python Beginner Weekend
6 Secret Message Encoder Python Advanced 1-2 Weeks
7 Derivative Explorer Python Intermediate Weekend
8 Area Estimator Python Intermediate Weekend
9 The Data Detective Python Advanced 1 Week
10 The 3D Renderer Python Expert 2 Weeks
11 Epidemic Simulator Python Intermediate 1 Week

For beginners: Start with Project 1, then Project 2, then Project 5. For intermediate: Jump to Project 3 (Trig) and Project 7 (Calculus). For advanced: Focus on Project 6 (Matrices) and Project 10 (3D Rendering).

Expected Outcomes

After completing these projects, you will:

  • Stop seeing Algebra as “moving letters” and start seeing it as “logic balance.”
  • Understand that Calculus is just doing simple things (slope/area) millions of times.
  • Visualize Matrices as geometric transformers, not just grids of numbers.
  • Never be afraid of a math formula again, because you know you can code a simulation to understand it.

You’ll have built 11 working projects that demonstrate deep understanding of Math from first principles.