Member-only story
Hi everyone, welcome back. In these examples, we will be going over the constants that are included within the math module. The math module is a module that is provided by Python that contains mathematical functions that can be used in your project. We will be going over the constants that are provided within the math module. With this introduction out of the way, let’s get into it.
Importing The Math Module
We will need to import the math module into our project in order to access its functions and properties. Let’s see how we can do that:
import math
Now that our math module is imported into our project, let’s start going over the constants that are provided.
Constants
Pi
Let’s start by going over the pi constant. We can access this value by using the pi constant. Let’s see an example:
import math
print(math.pi)Output:
3.141592653589793
In the example above, we can see that we are successfully retrieving the pi constant from the math module.
E
Now let’s see how we can access the e(Euler’s number) constant. We can access this value by using the e…