Although Python provides lots of operators to perform various operations, to make programming easier it has very useful in-built functions.
These are present in math module. The progammer just has to do an import of this module,
Function Name |
Usage |
sin(x) |
returns the sine of value passed as argument. The value passed in this function should be in radians
sin(0.88) : 0.77
sin(0) : 0.0
|
radians(x) |
Used to convert specified angle to radians. |
floor(x) |
Decreases value to the previous integer value
floor(4.3) : 4.
|
pow(x,y) |
Used to raise x value toy
Example :
pow(5,2) : 25
|
sqrt(x) |
Used to get square root of the value passed as argument.
sqrt(25) : 5
|
cos(x) |
Returns the cos of value passed as argument.
cos(-3) : -0.9899924966
cos(0) : 1.0
|
log(x,[base]) |
Used to get natural algorithm of x specified base.
log(5.5,2) : 2.45943
|
factorail(x) |
Used to get factorail of the value passed as argument.
factorial(23): 2585201673
|
gcd(x,y) |
Used to get common divisor of x and y
math.gcd(60, 48) : 12
|
trunc(x) |
Used to get integer value of the value passed as argument |
isinf(x) |
Checks if the value entered is positive infinity or negative infinity |
isnan(x) |
Checks if the value entred is 'Not A Number' and returns true if the value is 'Not A Number'.
isnan(0.007) : False
isnan(float('NaN')) : True
|
fabs(x) |
Returns positive value of the value passed as argument.
fabs(-13.1) : 13.1
fabs(101.96) : 101
|
fmod(x,y) |
Returns the remainder division of x and y.
fmod(25,5) : 0.0
fmod(20,3):2.0
|
fsum(x,y,z....) |
Returns the Sum of all values passed as argument
Eaxmple :
fsum(1,2,5,-2) : 6
|
exp(x) |
Returns exponentiational value of the value passed as argument
Eaxmple :
exp(0.5) : 1.64872
|
ceil(x) |
Returns the next postive integer
Example :
math.ceil(-45.17) : -45.0
math.ceil(100.12) : 101.0
.
|