A hands-on introduction to Python for first-year engineering students. Every module starts from an engineering problem (a beam, a circuit, a cooling tank, a strain gauge) and introduces exactly the Python needed to solve it.
- First-year engineering students with no prior programming experience.
- Instructors and TAs running a 12–14 week course (see
syllabus.md). - Self-learners: every module is self-contained and runs in Colab with one click.
Option A – zero install (Colab). Click the Colab badge on any notebook. Exercise notebooks fetch the autograder and datasets themselves, so you can complete and check every module without installing anything.
Option B – local install.
git clone https://github.com/ktwyw/python-for-engineers.git
cd python-for-engineers
pip install -e ".[dev]" # installs numpy, scipy, matplotlib, pandas, pytest, ...
jupyter labDetailed, OS-specific instructions live in setup/.
| # | Module | Engineering hook | Python you learn |
|---|---|---|---|
| 01 | Python basics | Projectile range | variables, types, if, for, while |
| 02 | Functions & modules | Unit conversion library | def, scope, import, docstrings |
| 03 | Lists, dicts, files | Bill of materials | lists, dicts, reading/writing text files |
| 04 | NumPy | Beam deflection, truss statics | arrays, vectorization, np.linalg.solve |
| 05 | Matplotlib | Stress–strain curves | figures, axes, styling, saving |
| 06 | SciPy | RC circuit, tank cooling | root finding, integration, ODEs, curve fit |
| 07 | pandas | Strain-gauge logger data | DataFrames, cleaning, groupby, time series |
| 08 | Testing & units | Safety-factor calculator | pytest, exceptions, pint |
| 09 | SymPy (optional) | Deriving Euler buckling | symbolic algebra, calculus |
| 10 | Capstone | Your choice | putting it all together |
Each module folder contains:
README.md learning objectives, prerequisites, estimated time
lecture.ipynb the guided lesson (run top to bottom)
exercises.ipynb graded exercises — implement the functions, run the tests
exercises.py the same exercises as a plain .py file (primary from module 02 on)
examples/ 2–3 short worked problems from other disciplines using this module's tools
data/ any datasets used in the module
The lecture in each module follows one problem; the examples/ folder shows the same
tools applied to mechanical, civil, electrical and chemical problems. See
examples-by-discipline.md to follow your own field through the course.
All ten modules are complete: lecture notebook, exercises (.py + Colab
mirror), and autograder tests for 01–09; a starter package and rubric for the
capstone; autograders for both projects. Every lecture notebook is executed
in CI.
Exercises are functions with fixed signatures. Tests in tests/
check your implementation:
pytest tests/test_module01.py # one module
pytest # everything (untouched exercises are skipped, not failed)
make check # what CI runs: strip notebooks, execute lectures, run testsProjects are graded the same way — see tests/projects/ and the interface
section of each brief in projects/.
If you're enrolled via GitHub Classroom the same tests run automatically when you push.
modules/ one folder per week
projects/ multi-week project briefs and rubrics
datasets/ shared data, each with a provenance README
cheatsheets/ one-page references
src/pyeng/ small helper package (plot styles, data loaders)
tests/ autograder tests
tools/ instructor scripts (notebook mirror generator, dataset sync)
solutions/ NOT in this repo — see CONTRIBUTING.md
- If you fork this repository, run
grep -rl ktwyw . | xargs sed -i 's/ktwyw/<your-github-username>/g'so badges, Colab links and the Colab grader point at your copy. - Create a private
python-for-engineers-solutionsrepo (seeCONTRIBUTING.md). make installthenmake check— CI runs the same checks on every push.- Read each module's README "Instructor notes" before teaching it.
Code is MIT; teaching materials are CC BY 4.0. See LICENSE.