Month 1 — Exercises collection
This page contains additional exercises on all topics. In addition to the exercises at the end of each chapter, complete these too — for deeper understanding.
🟢 Easy-level exercises
Math
- Create a
(5, 5)random matrix with NumPy, compute its rank. - Compute variance and standard deviation of vector
[2, 4, 6, 8, 10]by hand and with NumPy. - Explain whether the following statements are true or false:
- “Mean is always the best measure of central tendency”
- “Standard deviation is the square root of variance”
NumPy
- Using
np.eye(5), create a5x5identity matrix. - Reshape
[1, 2, 3, 4, 5, 6, 7, 8, 9]to a(3, 3)matrix and take its transpose. - Compute Euclidean distance between two random
(100,)vectors.
Pandas
- Read a CSV file and output the first 5 rows in
JSONformat. - Replace spaces in column names with
_(df.columns.str.replace). - Find both empty and
0values in aDataFrame, output their count.
Visualization
- Plot sine and cosine functions on one chart.
- Plot
bar plotin 4 different colors. - For a random
(50, 50)matrix, plot heatmap usingimshow.
🟡 Medium-level exercises
Working with real datasets
- Iris dataset: load via
seaborn.load_dataset('iris'). Plot distribution of each feature byspeciesusing violin plot. - Tips dataset: load
seaborn.load_dataset('tips'). Output averagetipbydayandtimeas a pivot table. - Custom dataset: export real data from your Django/FastAPI project (orders, users, events) and start EDA.
Vectorization exercises
- Implement function
sigmoid(x) = 1 / (1 + exp(-x))in NumPy. Compare with pure Python loop for 1M elements. - Implement
softmax(x) = exp(x) / sum(exp(x))— with numerical stability (x - max(x)). - Implement moving average —
(window=10), no loops in NumPy.
Pandas pipelines
- E-commerce funnel: compute user transition rates
view → cart → purchase. - Cohort retention: divide users into cohorts by registration month, plot 6-month
retention. - RFM Analysis: compute Recency, Frequency, Monetary metrics for each customer and split into segments.
🔴 Hard-level exercises (Backend integration)
1. Analytics API (FastAPI)
Create a complete FastAPI service with the following endpoints:
POST /api/v1/analytics/upload # CSV/JSON dataset yuklash
GET /api/v1/analytics/{id}/summary # describe() natijasi
GET /api/v1/analytics/{id}/chart # PNG chart qaytarish
GET /api/v1/analytics/{id}/report # ydata-profiling HTML
POST /api/v1/analytics/{id}/query # custom SQL-like so'rov
Requirements:
- Store loaded datasets in Redis or on disk (with TTL)
- Fully type-safe with Pydantic models
- Automatic OpenAPI docs
- Unit tests with Pytest
2. Django Admin Reports
Add a admin custom action to your existing Django project (or create a new one):
- PDF report generation for selected objects
- Charts using Pandas + matplotlib
- PDF via ReportLab or WeasyPrint
3. Real-time Dashboard
Create a real-time dashboard with Server-Sent Events (SSE):
- FastAPI backend serves fresh data every 5 seconds
- Frontend (simple HTML+Chart.js)
- Pandas aggregates on the backend side
- Plotly sends data in JSON format
4. Data Quality Service
Using Pandera or Great Expectations:
- Schema validation for uploaded CSV
- Quality score (0-100)
- Detect anomalies (outliers, type mismatch)
- Slack notification on incorrect data
Mini-projects (each 1-2 weeks)
Mini-project 1: Personal Finance Tracker
- Your own bank statement (CSV)
- Categorization via Pandas (rules-based)
- Monthly expenses dashboard
- Trends and anomalies
- Interactive UI in Streamlit
Mini-project 2: GitHub Profile Analyzer
- Load your repos from GitHub API
- Code distribution by language
- Commit activity (calendar heatmap)
- Top contributors
- Automatically embed in README
Mini-project 3: Uzbekistan Open Data EDA
- Take dataset from data.gov.uz and do EDA
- Write insights in Uzbek
- Publish as a post on Habr.com/dev.to
Quiz (self-test)
Pandas
- What’s the difference between
df.iloc[0]anddf.loc[0]? - Difference between
df.merge()withhow='left'andhow='outer'? - When are
apply()andmap()used? - Difference between
transform()andagg()? - How to optimize a large DataFrame in memory? (
categorydtype,downcast)
NumPy
- Difference between
np.arrayandnp.asarray? - Explain the broadcasting rule.
- What’s the difference between
np.copy()and[:]slicing? - Relation of
axis=0andaxis=1to(rows, cols)? - Does
np.vectorize()really make things faster? (Hint: no!)
Math
- Formula of
cosine similarityand why is it used? - What happens if the
learning rateingradient descentis too large? - Difference between normal distribution and uniform distribution?
- Explain Bayes theorem in your own words.
correlation = 0— does this always mean “no relationship”? (Hint: no, only no linear relationship)
✅ End-of-month checklist
- Math chapter completed, gradient descent code written
- NumPy exercises completed, I understand broadcasting
- Pandas EDA exercises (Titanic / House Prices)
- Visualization exercises, FastAPI endpoint returning PNG
- Capstone: one complete EDA project on GitHub
- LinkedIn post (with link to project)
Congratulations! Ready for Month 2 — Classical ML.