Math Module
Python has a built-in module that you can use for mathematical tasks. The math module has a set of methods and constants.
Method | Description |
math.sqrt() | Returns the square root of a number |
math.factorial() | Returns the factorial of a number |
math.gcd() | Returns the greatest common divisor of two inte-gers |
math.pow() | Returns the value of x to the power of y |
math.fsum() | Returns the sum of all items in any iterable (tuples, arrays, lists, etc.) |
math.prod() | Returns the product of all the elements in an iter-able |
math.comb() | Returns the number of ways to choose k items from n items without repetition and order |
math.perm() | Returns the number of ways to choose k items from n items with order and without repetition |
math.fabs() | Returns the absolute value of a number |
math.copysign() | Returns a float consisting of the value of the first parameter and the sign of the second parameter |
math.dist() | Returns the Euclidean distance between two points (p and q), where p and q are the coordinates of that point |
math.ceil() | Rounds a number up to the nearest integer |
math.floor() | Rounds a number down to the nearest integer |
math.fmod() | Returns the remainder of x/y |
math.remainder() | Returns the closest value that can make numerator completely divisible by the denominator |
math.degrees() | Converts an angle from radians to degrees |
math.radians() | Converts a degree value into radians |
math.sin() | Returns the sine of a number |
math.cos() | Returns the cosine of a number |
math.tan() | Returns the tangent of a number |
math.sinh() | Returns the hyperbolic sine of a number |
math.cosh() | Returns the hyperbolic cosine of a number |
math.tanh() | Returns the hyperbolic tangent of a number |
math.asin() | Returns the arc sine of a number in radians |
math.acos() | Returns the arc cosine of a number in radians |
math.atan() | Returns the arc tangent of a number in radians |
math.asinh() | Returns the inverse hyperbolic sine of a number |