How to Import Maths Module in Python
Maths module is already included with python installation.
To import any module in your program you must use:
import <modulename>
To import Math module write:
>>>import math
Example
>>> print(pi)
NameError: name ‘pi’ is not defined
>>> import math
>>> print(math.pi)
3.141592653589793
>>> print(pi)
NameError: name ‘pi’ is not defined
We must use math. before calling any method or variable of math module.
>>> math.factorial(5) # To calculate factorial
120
>>> math.e
2.718281828459045

Ankit Srivastava is an IT trainer, technology educator, and digital skills mentor with expertise in programming, data analytics, AI, and software development. He has successfully trained thousands of learners, with more than 10,000 student enrollments on Udemy. His practical teaching approach empowers students and professionals to build in-demand technical skills. Colorstech channel where Ankit posts video tutorials has more than 8000 Subscribers.


