For advanced math problems, we might have a hard time writing the code manually. Thankfully, we have the math module in python which solves complex mathematical problems for us
First, we’ll see some Built-in Math Functions, given to us in python
Max and Min
In order to find the lowest or highest value in a list, we use max and min functions.
|list = [1, 2, 3, 4]|
|a = max(list)|
|b = min(list)|
Absolute value can be referred the distance of the number from zero
The Math Module
For advanced mathematics, python has created a package called math.
Let’s see it in action!
Here we are importing math and using it to find the square root of 64
|a = 64|
Factorial means the product of all positive numbers less than or equal to the number for which we want
to find the factorial
We can also use the math module in Trignometry.
a = 22 # radians
Here we are able to find the sin for an angle of 22 in radians.