This notebook contains an excerpt from the Python Programming and Numerical Methods - A Guide for Engineers and Scientists, the content is also available at Berkeley Python Numerical Methods.

The copyright of the book belongs to Elsevier. We also have this interactive book online for a better learning experience. The code is released under the MIT license. If you find this content useful, please consider supporting the work on Elsevier or Amazon!

< Preface | Contents | 1.1 Python Basics >


The first version of this book was written at a time when the standard generalist language taught in engineering (and beyond) at UC Berkeley was Matlab. Its genesis goes back to the mid-2000s, which precede the current era of data science, machine learning, in which Python emerged as a commonly used language across the engineering profession. The first version was thus written as part of the E7 class at UC Berkeley, which introduces many students to programming and numerical analysis. It would never have been written without the help of colleagues, teams of Graduate Student Instructors (GSI), graders, and administrative staff members who helped us through the challenging process of teaching E7 to several hundreds of students each semester at UC Berkeley. Furthermore, the first edition of this book would never have reached completion without the help of the students who had the patience to read the book and give us their feedback. In the process of teaching E7 numerous times, we have interacted with thousands of students, dozens of GSIs and graders, and a dozen colleagues and administrators, and we apologize to those we will inevitably forget given the number of people involved. We are extremely grateful for guidance from our colleagues Professors Panos Papadopoulos, Roberto Horowitz, Michael Frenklach, Andy Packard, Tad Patzek, Jamie Rector, Raja Sengupta, Mike Cassidy, and Samer Madanat. We owe thanks particularly to Professors Roberto Horowitz, Andy Packard, Sanjay Govindjee, and Tad Patzek for sharing the material they used for the class, which contributed to the material in this book. We also thank Professors Rob Harley and Sanjay Govindjee for using a draft of this book during the semesters they taught E7 and giving us feedback that helped improve the manuscript. The smooth running of the semester course gave the authors the time and energy to produce this book. Managing the course was greatly facilitated by numerous administrative staff members who bore much of the logistic load. We are particularly grateful to Joan Chamberlain, Shelley Okimoto, Jenna Tower, and Donna Craig. Civil and Environmental Engineering Vice Chair Bill Nazaroff deserves particular recognition for assigning the second author to teach the class in 2011. Without this assignment the two authors of this book would not have had an opportunity to work together and write this book. E7 is notoriously the hardest class to teach at UC Berkeley in the College of Engineering. However, it continued to run smoothly over the many semesters we learned to teach this class, mainly due to the help of the talented GSIs we had the pleasure of working with. During the years the coauthors taught the class, a series of legendary head GSIs have contributed to shaping the class and making it a meaningful experience for students. In particular, Scott Payne, James Lew, Claire Saint-Pierre, Kristen Parish, Brian McDonald, and Travis Walter have in their respective roles led a team of dedicated GSI to exceed expectations. The GSI and grader team during the Spring of 2011 greatly influenced the material of this book. For their contribution during that critical semester, we thank Jon Beard, Leah Anderson, Marc Lipoff, Sebastien Blandin, Sam Chiu, Rob Hansen, Jiangchuan Huang, Brad Adams, Ryan Swick, Pranthik Samal, Matthieu Lewandowski, and Romain Bourcier. We are also grateful to Claire Johnson and Katherine Mellis for finding errors in the text and helping us incorporate edits into the manuscript. We are indebted to the E7 students for their patience with us and their thorough reading of the material. Having seen thousands of them through the years, we are sorry to only be able to mention a few for their extraordinary feedback and performance: Gursham-njot Singh, Sabrina Nicolle Atienza, Yi Lu, Nicole Schauser, Harrison Lee, Don Mai, Robin Parrish, and Mara Minner. In 2018, as the UC Berkeley campus was already deeply engaged in the transition leading to the birth of the Division of Computing, Data Science, and Society, numerous conversations started on the need for UC Berkeley students to learn Python, which in the mean time had become a commodity of choice for employment in most tech companies. Thus, this book started with the intention of preparing engineering and science students with basic data science tools. The UC Berkeley Division of Computing, Data Science, and Society played an active role in creating this book for a lower division course to prepare students for further study. We thank Cathryn Carson and David Culler for their support in writing this book and for the discussions on how to make it better. Their help happened in parallel to the herculean efforts they led to build the Division of Computing, Data Science, and Society. It is one of the many expressions of their scientific generosity and dedication to building a rich and innovative data science environment at UC Berkeley. We also appreciate the care and help from Eric Van Dusen and Keeley Takimoto. About two thirds of the book are adapted from the original Matlab version – An Introduction to MATLAB® Programming and Numerical Methods for Engineers by the two last authors. We thank Jennifer Grannen, Brian Mickel, Nick Bourlier, and Austin Chang for their help to convert some of the Matlab code to Python, and thank Christopher Pyles to build the interactive website using Jupyter book. We are (again!) grateful to Claire Johnson for her help with the second version of the book, and to Jennifer Taggart for finding errors in the text and helping us incorporate edits into the manuscript. Finally, we also thank the Berkeley Seismsology Lab for the support of writing this book and the Python training over the years.