Master the foundational language of Artificial Intelligence: Python 3, object-oriented principles, virtual environments, and high-performance array operations with NumPy.
- Basic computer literacy and logical thinking.
- No prior programming experience required.
- Python Fundamentals:
- Variables, dynamic typing, primitive data types (int, float, str, bool).
- Control flow:
if-elif-else,while, andforloops. - Built-in data structures: Lists, Tuples, Sets, and Dictionaries.
- Functions,
*args,**kwargs, lambda expressions, and scope.
- Object-Oriented Programming (OOP) for ML:
- Classes, attributes, methods,
__init__, and__call__(crucial for custom PyTorch modules). - Inheritance and polymorphism.
- Classes, attributes, methods,
- Environment Management:
- Why virtual environments matter.
- Using
python -m venvto isolate dependencies. - Installing and freezing requirements (
pip install,pip freeze > requirements.txt).
- Numerical Computing with NumPy:
- Multidimensional arrays (
ndarray), shape, dimensions, and data types (dtype). - Slicing and fancy indexing.
- Vectorization vs. slow Python loops.
- Broadcasting rules.
- Linear algebra functions (
np.dot,@,np.linalg.inv,np.linalg.eig).
- Multidimensional arrays (
- Read The Python Tutorial (Chapters 1 to 5).
- Set up a local virtual environment in VS Code.
- Practice writing modular functions and custom classes.
- Read the NumPy Quickstart Tutorial.
- Complete the practical exercises below.
Implement Euclidean distance between two vectors using NumPy without using any for loops:
import numpy as np
def euclidean_distance(v1: np.ndarray, v2: np.ndarray) -> float:
"""Calculate Euclidean distance using vectorized NumPy operations."""
diff = v1 - v2
return np.sqrt(np.sum(diff ** 2))
# Test
a = np.array([1.0, 2.0, 3.0])
b = np.array([4.0, 6.0, 8.0])
print("Distance:", euclidean_distance(a, b)) # Expected ~6.403Benchmark the performance difference between a 3-loop native Python matrix multiplication vs. np.dot / @ on two
- Statistical CLI Tool: A command-line Python script that reads any CSV file, parses numbers, and computes mean, median, standard deviation, and IQR using NumPy.
- Custom Array Class: Build an educational mini-array class from scratch with basic element-wise addition, subtraction, and dot product.