Python & Math for AI Notes
Subject Overview
The opening semester of Year 1 (Foundations), aimed at becoming productive in Python and comfortable with the mathematical language of machine learning. Five modules of 4 hours each take you from variables and control flow through the scientific Python stack to the linear algebra, calculus and probability that the rest of the programme assumes. Year 1 as a whole builds the technical bedrock: programming fluency, the maths you actually need, and the classical ML techniques that still power most real-world systems.
Subject at a glance
7
Units
36
Topics
15
Hours
7
Infographics
Unit-wise Syllabus
7 units — click WhatsApp below to get the full notes for each
Unit 1: Python Essentials (4 hours)
- Variables
- control flow
- functions
- data structures
- file I/O
- exception handling
- building muscle memory in the editor
list
Ordered, mutable
[1, 2, 3]
tuple
Ordered, immutable
(1, 2)
dict
Key-value, mutable
{"name": "Ana"}
set
Unordered, unique items
{1, 2, 3}
Study guide
This module builds your Python base: variables, control flow, functions, data structures, file input and output and exception handling. The aim is muscle memory: typing code daily until the syntax stops getting in your way. Write small programs in the editor every day rather than only reading.
Unit 2: Pythonic Code & OOP (4 hours)
- List comprehensions
- generators
- decorators
- classes
- modules
- virtual environments (venv, uv)
- packaging basics
- List comprehension
- [x * x for x in nums if x > 0]
- Generator
- Yields items lazily, saves memory
- Decorator
- Wraps a function to add behaviour (@timer)
- Class
- Blueprint bundling data and methods
- Virtual environment
- Isolated packages per project (venv, uv)
Study guide
You move to idiomatic Python: list comprehensions, generators, decorators, classes, modules, virtual environments (venv, uv) and packaging basics. Virtual environments keep each project's libraries separate, which prevents many common errors.
Unit 3: Scientific Python Stack (4 hours)
- NumPy arrays and broadcasting
- Pandas DataFrames
- Matplotlib and Seaborn for visualization
NumPy
Fast n-dimensional arrays, broadcasting
Pandas
DataFrames: load, clean, group, join
Matplotlib
Low-level plotting
Seaborn
Statistical charts on top of Matplotlib
Jupyter / Colab
Interactive notebooks
Study guide
The scientific stack is the toolbox of every AI engineer: NumPy arrays and broadcasting, Pandas DataFrames and Matplotlib and Seaborn for visualisation. Try each library on a real CSV file rather than toy data.
Unit 4: Linear Algebra for ML (4 hours)
- Vectors
- matrices
- dot products
- matrix multiplication
- eigenvalues
- the intuition behind embeddings
Dot product
a · b = Σ ai bi = ‖a‖ ‖b‖ cos θ
Matrix multiply
(m × n) × (n × p) gives (m × p)
Eigenvector
A v = λ v
Cosine similarity
a · b / (‖a‖ ‖b‖)
How similar two embeddings are
Study guide
Linear algebra is the language of machine learning: vectors, matrices, dot products, matrix multiplication, eigenvalues and the intuition behind embeddings. Think of a vector as a point in space and a matrix as a transformation of that space.
Unit 5: Calculus & Probability (4 hours)
- Derivatives
- gradients
- the chain rule
- probability distributions
- Bayes' theorem
- expectation
Gradient
∇f = vector of partial derivatives
Chain rule
dz/dx = dz/dy × dy/dx
The heart of backpropagation
Gradient descent
w ← w − η ∇L(w)
Bayes' theorem
P(A given B) = P(B given A) P(A) / P(B)
Expectation
E[X] = Σ x P(x)
Study guide
Calculus and probability explain how models learn: derivatives, gradients, the chain rule, probability distributions, Bayes' theorem and expectation. The chain rule is the idea behind backpropagation, so make sure you understand it.
Unit 6: Tools introduced
- VS Code or Cursor as primary editor
- Git and GitHub (branches, PRs, basic collaboration)
- Jupyter notebooks and Google Colab
- GitHub Copilot for inline suggestions — learning when to accept versus reject
- 1
Clone or create a repo
- 2
Create a branch
git checkout -b feature
- 3
Commit changes
git add, git commit
- 4
Push to GitHub
- 5
Open a pull request
Review and discuss
- 6
Merge into main
Study guide
You set up a professional toolkit: VS Code or Cursor as the editor, Git and GitHub (branches, pull requests, collaboration), Jupyter and Google Colab notebooks and GitHub Copilot for inline suggestions, learning when to accept and when to reject its output. Commit your work to GitHub from week one.
Unit 7: Mini-projects
- CLI expense tracker with file persistence
- stock price analyzer using NumPy/Pandas on a real CSV
- a tiny linear regression solver built from scratch with no libraries
- 1
Load data into NumPy arrays
- 2
Initialise weights w and bias b
- 3
Predict
ŷ = w x + b
- 4
Compute loss
Mean squared error
- 5
Compute gradients and update
- 6
Repeat until loss stops falling
Study guide
The mini-projects tie it together: a command-line expense tracker with file persistence, a stock price analyser using NumPy and Pandas on a real CSV and a tiny linear regression solver built from scratch with no libraries. Building regression from scratch shows what libraries do for you.
Why Python & Math for AI Matters
Python and the mathematics behind it are the entry ticket to every AI role. This first semester gives you the programming fluency, the maths intuition and the workflow tools (Git, notebooks, AI-assisted coding) that the rest of the programme builds on, and mini-projects you can show on GitHub.
How to Prepare for Python & Math for AI
- Code every day and commit to GitHub; a visible history is a portfolio.
- Learn the maths through visuals and code, not only formulas.
- Use AI coding assistants as a tutor, but always understand the code you accept.
Python & Math for AI: Frequently Asked Questions
Do I need to know Python before the B.Sc IT with AI programme?
No. The first module starts from Python essentials and builds up to object-oriented code and the scientific stack.
Why is linear algebra important for AI?
Models represent data as vectors and matrices, and training and inference are matrix operations, so linear algebra is the language of machine learning.
