The math
module is a built-in Python library. It helps in numerous mathematical functions following the C standard.
This works for real numbers only.
Functions | Description |
---|---|
math.ceil( value ) | It returns the smallest integer greater than or equal to value. |
math.copysign( value1,value2 ) | It returns the float with magnitude of value1 and sign of value2. |
math.fabs( value ) | It returns the absolute of value. |
math.factorial( value ) | It returns the factorial of value. |
math.floor( value ) | It returns the largest integer greater than or equal to value. |
math.fsum( iterable ) | It returns the float sum of the values of the iterable. |
# Importing Math library.import math#ceiling functionprint(math.ceil(10.555))#factorial functionprint(math.factorial(3))
There are numerous other functions as well:
# Importing Math library.import math# tangent functionprint(math.atan(90))# power functionprint(math.pow(3,2))# pi constantprint(math.pi)
Copyright ©2024 Educative, Inc. All rights reserved.