WhatsApp and Telegram Group Card
WhatsApp Group Join Now
Telegram Group Join Now

Math Module in Python : Python Concepts

Math Module in Python : As we know, there is a concept of modules in python, Modules is nothing but the ‘A file that contains a collection of related function is called as Module. We can perform a number of mathematical operations in python with ease by importing a module named “math” which define various function which makes our tasks easier.

Python provide mathematical functions by using math module. When we want to use math function first we have to import math module. This statement creates a module object named math.

Importing math module

>>>import math

Some methods of Math Module are :-

Math Module Methods
Sr. No.FunctionsDescription
1.math.ceil(x)Rounds a number to its nearest Integer.
2.math.fabs(x)This function returns the absolute value of X.
3.Math.isfinite(x)This function will returns the True if the x is not a infinite number nor a 
NAN ( Not a Number)
4.Math.truncate(x)This function will returns the only integer part of a number
5.Math.sqrt(x)This function will return the square root of anumber.
6.Math.pow(x,y)This function will return the value as x to power y.
Math Module Methods
Math Module Constant
Sr. No.ConstantDescription
1.Math.piReturns Pl (3.1415)
2.Math.eReturns Euler’s number (2.7182)
Math Module Constant

Examples

# Import math library
import math

print(math.ceil(1.4))
print(math.fabs(-66.43))
print(math.isfinite(2000))
print(math.trunc(2.77))
print(math.sqrt(9))
print(math.pow(9, 3))

Output

2
66.43
2000
2
3.0
729.0​

Hope, after going through the whole article, all your doubts are cleared related math module.

Also Read : Global Keyword in Python

Important Links

Join WhatsAppClick Here
Join TelegramClick Here
Join Twitter (X)Click Here
Join InstagramClick Here
Important Links