**Python Math Module**

**The math module is one of the most useful modules in python,it consists of all the mathematical operations.It provide access to many mathematical functions.It consists of various methods. Note this math module cannot be used with complex numbers.**

This method returns the nearest integer that is greater than or equal to the number.It always returns an integer

**Program**

import math

result=math.ceil(2.6)

print("result=",result)

**Output:**

result=3

**2)math.floor()**

This method returns the nearest integer that is lesser than or equal to the number.It always returns an integer.

**Program**

import math

result=math.floor(2.6)

print("result=",result)

**Output:**

result=2

**3)math.factorial()**

**This method returns the factorial of the given or specified integer.**

**Program**

import math

result=math.factorial(5)

print("result=",result)

**Output:**

result=120

**4)math.sqrt()**

**This method returns the square root of the given or specified integer.**

**Program**

import math

result=math.sqrt(181)

print("result=",result)

**Output:**

result=13.45362404707371

**5)math.gcd()**

**This method returns the greatest common divisor of the given or specified integers.It takes two arguments as input**

**Program**

import math

result=math.gcd(181,11)

print("result=",result)

**Output:**

result=1

**6)math.pow()**

**This method returns the power of the given or specified integers.It takes two arguments as input**

**Program**

import math

result=math.pow(181,11)#181 to the power 11

print("result=",result)

**Output:**

result=6.830686029298982e+24

**7)math.sin()**

**This method returns the sin of the given or specified integer.**

**Program**

import math

result=math.sin(45)

print("result=",result)

**Output:**

result=0.8509035245341184

**8)math.radians()**

**This method returns the radian value of the given or specified integer(degree)**

**Program**

import math

result=math.radians(45)

print("result=",result)

**Output:**

result=0.7853981633974483

Suppose you do not want to use math everytime ,you can use alias or you can import only the functions you need.

syntax:

import math as m #can use any name after as

**Program**

import math as m

result=m.radians(45)

print("result=",result)

**Output:**

result=0.7853981633974483

syntax:

from math import radians #can use any function after import

**Program**

from math import radians

result=radians(45)

print("result=",result)

**Output:**

result=0.7853981633974483

Happy Learning!!

## Comments

## Post a Comment