/    /  Python – Mathematics

# Python – Mathematics:

In python, we have the module called “math” which provides the access to mathematical functions which are defined in C programming.

Doing mathematics using python is always a fun.

There are 2 types of modules for mathematical functions.

1. math – This is used for normal numbers
2. cmath – This is used for complex numbers

There are different types of mathematical functions available in math module.

1. Number Functions
2. Power and logarthmic Functions
3. Trigonometric Functions
4. Angular conversion
5. Hyperbolic Functions
6. Special Functions
7. Constants

Examples of Number Functions:

```>>> from math import ceil, factorial, floor, gcd, fsum, trunc

# ceiling the value

>>>ceil(10.3)
11

>>>ceil(9.9)
10
# Factorial of given value

>>>factorial(3)
6

>>>factorial(10)
3628800

# Floor of value given
>>>floor(10.3)
10

>>>floor(10.9)
10

# calculates the GCD of given numbers
>>>gcd(5,10)```
```5

>>>gcd(3,7)

1```
```# Floating point sum of of values

>>>fsum([5,4,5,1])

15.0

# Truncating the values

>>>trunc(9.4)

9

>>>trunc(10.5)

10

>>>

Examples of Power and logarthmic Functions:```
```>>>math.exp(2)
7.38905609893065
>>>math.log(2,10)
0.30102999566398114

>>>math.log(2,4)
0.5

>>> math.log2(4)
2.0

>>> math.log10(2)```
```0.3010299956639812

>>math.pow(2,3)

8.0

>>>math.sqrt(64)

8.0```

Examples of Trigonometric Functions:

```>>> from math import sin, cos, tan

>>>sin(30)

-0.9880316240928618

>>>cos(90)

-0.4480736161291701

>>>tan(0)

0.0```

Examples of Angular conversion:

```>>> from math import degrees,radians

>>>degrees(10)
572.9577951308232