CME 100 Python Workbook#

This book is a work in progress

It is not currently being used in any class and things may break at any time.

This Jupyter Book contains a series of Python exercises aimed at introducing you to scientific computing in the context of CME 100: Vector Calculus for Engineers at Stanford University. The exercises are adapted from the MATLAB Workbook by Vadim Khayms, Senior Lecturer in Mechanical Engineering, and created by Enze Chen, Lecturer in Materials Science and Engineering. We hope students will find these exercises useful in their studies!

Important note for students

If you’re submitting work for credit, you only have to submit one of the MATLAB or Python exercises. You will not be rewarded for both, though you’re welcome to do both for practice. These pages only have Python, corresponding to the exercises in the original MATLAB Workbook.

Other FAQs#

What do I install?#

Nothing! Unlike the MATLAB exercises, we’ll be doing everything in the cloud. If you like the sound of this, keep reading the Usage tips for instructions on how to complete and submit your work.

Does it really not matter which language I learn?#

Pretty much. In the context of the course, homeworks and tutorials will still be given in MATLAB as we experiment with the transition to Python, but the underlying computing principles and computational thinking are the same. Sure, certain tasks may be easier in one language than the other as they were developed by different scientific communities, but we anticipate that learning one will serve as a solid foundation so you can easily transition to another programming language in your future work.

Somehow this feels less satisfying than CS 106A or DATASCI 112#

Possibly. We’re really sorry you feel this way and hope to hear from you how we can improve! In the meantime, we offer the following thoughts that may help with reframing.

  • In CS 106A and DATASCI 112, implementation is a core learning goal, so their pedagogy is aligned accordingly and the treatment is more thorough. Here it is ancillary to vector calculus concepts, so we offer weekly tutorials and this self-guided workbook to give you some practical tips, but we realize it is not comprehensive instruction.

  • Relatedly, here we hope to introduce you to numerical methods and how they can be applied in engineering. There are many other courses (in CME, EE, etc.) that go deeper into the theory and applications, which these exercises will position you well for.

  • On a philosophical level, there are slight differences between computer science, data science, and computational science (what we do). In a traditional CS course, you will gain a lot of experience with fundamental computing concepts like abstraction, decomposition, logic, object-oriented programming, style, etc. In computational science, we depend on all of this, but we focus more on the physical principles of the problem we’re trying to solve and how to (1) translate/embed them into the code, and (2) interpret results to guide design decisions. There are similarities, of course: we care about efficiency, stability, readability (of the code), etc. and we hope you can see these disciplines working in harmony to help you achieve your goals.