Skip to content

Repository files navigation

Python for Engineers

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.

Tests Open in Colab

Who this is for

  • 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.

Quick start

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 lab

Detailed, OS-specific instructions live in setup/.

Course map

# 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.

Status

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.

How grading works

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 tests

Projects 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.

Repository layout

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

Instructor quick start

  1. 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.
  2. Create a private python-for-engineers-solutions repo (see CONTRIBUTING.md).
  3. make install then make check — CI runs the same checks on every push.
  4. Read each module's README "Instructor notes" before teaching it.

License

Code is MIT; teaching materials are CC BY 4.0. See LICENSE.

About

Python for first-year engineering students: 10 modules from basics to NumPy, SciPy, pandas and testing, each built around an engineering problem, with Colab notebooks, autograded exercises and two projects

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages