Applying Math with Python
上QQ阅读APP看书,第一时间看更新

Technical requirements

In this chapter, and throughout this book, we will use Python version 3.8, which is the most recent version of Python at the time of writing. Most of the code in this book will work on recent versions of Python from 3.6. We will use features that were introduced in Python 3.6 at various points, including f-strings. This means that you may need to change python3.8, which appears in any terminal commands to match your version of Python. This might be another version of Python, such as python3.6 or python3.7, or a more general command such as python3 or python. For the latter commands, you need to check that the version of Python is at least 3.6 by using the following command:

          python --version
        

Python has built-in numerical types and basic mathematical functions that suffice for small applications that involve only small calculations. The NumPy package provides a high performance array type and associated routines (including basic mathematical functions that operate efficiently on arrays). This package will be used in many of the recipes in this chapter and the remainder of this book. We will also make use of the SciPy package in the latter recipes of this chapter. Both can be installed using your preferred package manager, such as pip:

          python3.8 -m pip install numpy scipy
        

By convention, we import these package under a shorter alias. We import numpy as np and scipy as sp using the following import statements:

import numpy as np
import scipy as sp

These conventions are used in the official documentation for these packages, along with many tutorials and other materials that use these packages.

The code for this chapter can be found in the Chapter 01 folder of the GitHub repository at https://github.com/PacktPublishing/Applying-Math-with-Python/tree/master/Chapter%2001.

Check out the following video to see the Code in Action: https://bit.ly/3g3eBXv.