26 math module in python
---math module-----
Use math module, to perform mathematical tasks on numbers
Built-in Math Functions
The min() and max() functions can be used to
find the lowest or highest value in an iterable:
x = min(2, 6, 8)
y = max(50, 100, 205)
print(x)
print(y)
----------
The abs()
The pow(x, y) function
---------------------------------------
The Math Module
----------------------
Python has also a built-in module called math,
which extends the list of mathematical functions.
To use it, you must import the math module:
import math
Example
import math
x = math.sqrt(9)
print(x)
Example
import math
x = math.ceil(1.4)
y = math.floor(1.4)
print(x) # returns 2
print(y) # returns 1
The math.pi constant, returns the value of PI (3.14...):
Example
import math
x = math.pi
print(x)
Comments
Post a Comment