# Python Math Module Functions: How to Use Math Module Functions

Python Math module function; Through this tutorial, i am going to show you about python math module functions and how to use math module methods in your Python program with import the math modules in Python.

A modules named Math is already built-in Python. And this module provides you with many mathematical methods. You can use the methods/functions of this module in your Python program.

## Python math module methods

See all the methods of math modules in python; as shown below list:

Tell me one more important thing. Before using the method of the Math module, the Math module has to be imported into your Python program.

Take simple example and in this example will show you how to import the Math module of Python into your Python program:

```# Square root calculation
import math
x = math.sqrt(4)
print(x)```

In the above example, import the math module and also used the sqrt() method of the math module.

### Ceil method in python

The `math.ceil()` method rounds a number upwards to the nearest integer, and returns the result.

```#Import math module
import math
#Round a number upward to its nearest integer
print(math.ceil(5.2))
#output 6```

### Copysign method in python

The `math.copysign()` method returns a float consisting of the value of the first parameter and the sign(+/-) of the second parameter.

```#Import math Module
import math
#Return the first value, with the sign of the second value
print(math.copysign(5, -1))
#output -5, 0```

### Fabs method in python

Let’s pass a number inside this method and it returns an absolute number.

```Result Size: 668 x 459
4
#Import math module
import math
​
#Remove - sign of given number
print(math.fabs(-55.44))
​
#Output 55.44```

### Factorial method in python

Inside this method, to pass a positive integer number and this method gives out the factorial of that number.

```#Import math Module
import math
#factorial of a number
print(math.factorial(5))
#output 120```

### Floor method in python

The python math floor() method is used to round a number to nearest downword integer.

```#Import math module
import math
#Round given number downward nearest integer
print(math.floor(1.3))
print(math.floor(5.8))
#Output 1, 5```

### fmod method in python

Python fmod() method, which is used to calculate the Module of the specified given arguments ( remainder (modulo) of x/y ).

```#Import math module
import math
x = 6
y = 2
#calculate mode
print(math.fmod(x, y))
#output 0, bacause 6/2 == 0```

### frexp method in python

This method returns mantissa and exponent as a pair (m, e) of a given value x, where mantissa m is a floating point number and e exponent is an integer value. m is a float and e is an integer such that x == m * 2**e exactly.

```Result Size: 668 x 508
5
#Import math Library
import math
​
#mantissa and exponent of a given number
print(math.frexp(5))
​
​#output (0.625, 3)```

### fsum method in python

python fsum() method, which is used to find the sum (in float) of the values of an iterable, it accepts an iterable object like an array, list, tuple, etc (that should contain numbers either integers or floats), and returns sum in float of all values.

```#import math module
import math
# iterable objects
a = range(10)   #range value
# print sum of all values of the iterable objects
print("fsum(a): ", math.fsum(a))
#output fsum(a):  45.0```

### isfinite methods in python

math.isfinite() method, which is used to check whether a given number is a finite number or not. And it accepts a number like integer/float, finite, infinite or NaN numbers. Returns True if the argument is a valid python number. Otherwise, return false.

```#import math module
import math
x = 10
y= float('inf')
print(math.isfinite(x))
print(math.isfinite(y))
#Output
#True
#False```

### math.isinf method in python

The isinf method, which is used to checks a given number is infinite or not. If yes, it returns True. Otherwise, it returns False.

```#import math module
import math
x = 10
y= float('inf')
print(math.isinf(x))
print(math.isinf(y))
#Output
#False
#True```

### isnan method in python

isnan() method, which used to check whether a given parameter is a valid number or not. If given number is a valid Python number (Positive or Negative). Then it will return False. Otherwise, return true.

```#import math module
import math
x = 10
y= float('nan')
print(math.isnan(x))
print(math.isnan(y))
#output
#False
#TRUE```