1.1. Why Python?#

You might be wondering “why should an engineer learn Python?” There are other programming languages in the engineering world such as MATLAB, LabView, C, Java. What makes Python useful for engineers?

Python is a powerful programming language#

Python defines the types of objects you build into your code. Unlike some other languages such as C, you do not need to declare the object type. The object type is also mutable, you can change the type of object easily and on the fly. There is a wide array of object types built into Python. Objects can change in size. Python objects can also contain mixed data types. Strings and floating-point numbers can be part of the same list.

Python has an extensive standard library. A huge number of object types, functions, and methods are available for use without importing any external modules. These include math functions, list methods, and calls to a computer’s system. There is a lot that can be done with the standard library. The first couple chapters of this book will just use the standard library. It can do a lot.

Python has over 100,000 external packages available for download and use. They are easy to install off of the Python package index, commonly called PyPI (“pie pee eye”). There is a Python package for just about everything. Some packages can: interact with the web, make complex computations, do unit conversions, plot data, work with .csv, .xls, and .pdf files, manipulate images and video, read data from sensors and test equipment, train machine learning algorithms, design web apps, work with GIS data, work with astronautical data, and many more added every day. In this book, we will use some of the more useful Python packages for engineers such as numpy, matplotlib, pandas, and scipy.

Python is easy to learn and use#

Engineers solve the world’s problems in teams. One way Python helps solve these problems faster than other programming languages is that it is easy to learn and use. Python programs tend to be shorter and quicker to write than a program that does a similar function in other languages. In the rapid design, prototype, test, iterate cycle programming solutions can be spun up quickly. Python is also an easy language for fellow engineers on your team to learn. It is also quite human-readable. While programmers can become preoccupied with a program’s run time, it is development time that takes the longest.

Python is transportable#

Python can be installed and run on each of the three major operating systems: Windows, MacOS, and Linux. On Mac and Linux Python comes installed out of the box. Just open up a terminal in Mac OSX or Linux machine and type python. That’s it, you are now using Python. On Windows 10, I recommend downloading and using the Anaconda distribution.

Python is free#

MATLAB and LabView cost students and colleges to use and cost companies even more. Python is free to download and use. It is open source. Anyone is free to modify, contribute to, and propose improvements.

Python is growing#

Python is growing in popularity. It is particularly growing in the data sciences and in use with GIS systems, physical modeling, machine learning, and computer vision. These are growing team problem-solving areas for engineers.