Maths Module in Python Language

BySlide Scope

Maths Module in Python Language

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

About the author

Slide Scope administrator

Slide Scope Posts are written by experts from Core Information Technology and Digital Marketing Industry. We have assistants from Management Science as well.

Leave a Reply