Why Python?
Why Python?
You might be wondering "Why should I learn Python?" There are other programming languages in the engineering world such as MATLAB, LabView, C++ and Java. What makes Python useful for problem solving?
Python is a powerful programming language
Python can be used for large projects that run at scale. Some companies and websites that use Python are YouTube, Instagram, Facebook, Netflix and Dropbox.
Python is also used in cutting edge scientific research at CERN to investigate sub-atomic particles and was part of the analysis to prove the existence of gravitational waves using data from the LIGO experiment.
Python is easy to learn and use
Problem solvers work to solve the world's problems in temas. One way Python helps solve these problems faster than other programming languages is that it is easy to learn and use. A Python program tends to be shorter and quicker to write than a program that solves the same problem written in other computer programming language. In the rapid design, prototype, test, iterate cycle programming solutions made with Python can be spun up quickly. Python is also an easy language for fellow engineers on your team to learn. Python code is also quite human readable. While programmers can become preoccupied with a program's execution speed, development time takes the longest. Shorter development times mean problems are often solved faster using Python.
Python is transportable
Python can be installed and run on each of the three major operating systems: Windows, MacOS and Linux. On MacOS and Linux, Python comes installed right out of the box. On Windows, I recommend downloading and using the Anaconda distribution of Python. The Anaconda distribution of Python is free and can be installed on each of the three major operating systems, Windows, MacOS and Linux. The same Python programming environment can be replicated across these three operating systems.
Python is free
Some computer programming languages such as MATLAB and LabView cost students money to use and cost companies and colleges even more. Python is free to download and use. Python is also open source, and users are free to modify, contribute, and propose improvements to Python. All of the packages available for download on the Python Package Index, PyPI (pronounced pie-pee-eye) are free to download and install as well. Many more packages, scripts and utilities can be found in free open source repositories on GitHub, GitLab and Bitbucket.
Python is growing
Python is growing in popularity. Python is particularly growing in the area of data science and in use with GIS systems, physical modeling, machine learning and computer vision. These are growing team problem solving areas for engineers.
Python has extensive standard library of modules and a vast array of external modules
The Python Standard Library
Python has an extensive Standard Library. The modules available in the Python Standard Library can be used without an additional installation. Standard Library modules are built into Python. A huge number of object types, functions and methods are available for use without importing any external modules. Some functions and methods in the Python Standard Library include math functions, list methods, calls to a computer's operating system and much more. A lot of problem solving can be done with the Python Standard Library. The first couple chapters of this book will just use Python's Built-in modules and modules in the Standard Library.
A table of useful Python Standard Library modules for problem solving is below:
Standard Library module | utility |
---|---|
math |
mathematical functions |
statistics |
statistical functions |
sys |
system functions |
os |
operating system functions |
datetime |
date and time functions |
string |
string functions |
random |
pseudo random numbers |
csv |
reading and writing .csv files |
urllib |
web address functions |
The complete Standard Library can be found on Python Read-the-docs: https://docs.python.org
External Modules available on PyPI
Python has over 100,000 external packages available for download and use. These external packages 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. There are packages which can help you with: web interactions, complex computations, unit conversions, plotting, working with .csv, .xls, and .pdf files, images manipulation, sensors and test equipment, machine learning, web apps, GIS data and many more added every day. In this book, we will use some of the more useful Python packages for engineers such as jupyter, numpy, and matplotlib.
A table of useful third-party packages for problem solving is below:
package | utility |
---|---|
numpy | numerical calculations with homogenous arrays |
matplotlib | plotting and data visualization |
jupyter | interactive notebook computing environment |
pandas | dataframe functionality |
sympy | symbolic Math |
pyserial | serial port communication |
flask | web development |
pint | unit conversions |
schemdraw | circuity diagrams |
External modules from PyPI are downloaded and installed using the command line the Anaconda Prompt. To install a new module from PyPI use the command:
> pip install module_name
Just change module_name
to the name of the module you want to install.