Python math Module Functions

Beginner
7 min read
Updated: Nov 2026
62 function guides
Function index

About This Index

This page is the Python math Module Functions index for the tutorial track. Each row links to a full guide with syntax, parameters, return type, error rules, three runnable scripts, and FAQs.

Start with the math module hub for imports, constants, float precision traps, and comparisons with built-in functions. Use this page to jump straight to sqrt(), isclose(), floor(), or gcd().

Module functions and version notes.

Always run import math before calling math.*. Most functions return a float, while integer helpers such as ceil(), floor(), isqrt(), gcd(), and comb() return an int. Newer additions such as cbrt()/exp2() (3.11), sumprod() (3.12), fma() (3.13), and recent additions like fmax() note their Python version inside each guide.

How to Call a math Function

Import math at the top of your script and call functions through the module name:

Python
import math

print(math.sqrt(16))           # 4.0
print(math.floor(-2.5))        # -3
print(math.gcd(12, 18))        # 6
print(math.degrees(math.pi))   # 180.0
print(math.isclose(0.1 + 0.2, 0.3))  # True

Python math Module Constants

Five ready-to-use constants live alongside the functions in math:

ConstantTypeMeaning
math.pifloatRatio of circumference to diameter, approximately 3.141592653589793.
math.efloatEuler's number, base of the natural logarithm, approximately 2.718281828459045.
math.taufloatCircle constant equal to 2 * pi, approximately 6.283185307179586 (Python 3.6+).
math.inffloatFloating-point positive infinity, equivalent to float("inf") (Python 3.5+).
math.nanfloatFloating-point Not a Number, equivalent to float("nan") (Python 3.5+).

Python math Functions Table

All 62 function guides in the math module, grouped by purpose.

Powers, roots, and distances

6 functions

Square and cube roots, exact integer roots, float exponentiation, and Euclidean norms or point distances.

FunctionReturnsDescriptionTutorial
sqrt()floatReturn the square root of x as a float.Try it
cbrt()floatReturn the real cube root of x as a float (Python 3.11+).Try it
isqrt()intReturn the integer square root of a non-negative integer.Try it
pow()floatRaise x to power y and return a float.Try it
hypot()floatReturn the Euclidean norm sqrt(sum(x*x)) without overflow.Try it
dist()floatReturn the Euclidean distance between two points p and q.Try it

Exponentials and logarithms

7 functions

Base-e, base-2, and base-10 powers and logs, plus high-precision helpers for values near zero.

FunctionReturnsDescriptionTutorial
exp()floatReturn e raised to the power x as a float.Try it
exp2()floatReturn 2 raised to the power x as a float (Python 3.11+).Try it
expm1()floatReturn exp(x) - 1 accurately for values near zero.Try it
log()floatReturn the natural logarithm, or logarithm to a given base.Try it
log2()floatReturn the base-2 logarithm of x as a float.Try it
log10()floatReturn the base-10 logarithm of x as a float.Try it
log1p()floatReturn the natural logarithm of 1 + x accurately near zero.Try it

Trigonometry and angle conversion

9 functions

Sine, cosine, tangent, inverse trig functions (including quadrant-aware atan2), and degree/radian helpers.

FunctionReturnsDescriptionTutorial
sin()floatReturn the sine of x radians as a float.Try it
cos()floatReturn the cosine of x radians as a float.Try it
tan()floatReturn the tangent of x radians as a float.Try it
asin()floatReturn the arc sine (inverse sine) of x in radians.Try it
acos()floatReturn the arc cosine (inverse cosine) of x in radians.Try it
atan()floatReturn the arc tangent (inverse tangent) of x in radians.Try it
atan2()floatReturn atan(y / x) in radians using signs of both arguments.Try it
degrees()floatConvert angle x from radians to degrees.Try it
radians()floatConvert angle x from degrees to radians.Try it

Hyperbolic functions

6 functions

Hyperbolic sine, cosine, tangent, and their inverses for catenaries, rapidities, and smooth scaling.

FunctionReturnsDescriptionTutorial
sinh()floatReturn the hyperbolic sine of x as a float.Try it
cosh()floatReturn the hyperbolic cosine of x as a float.Try it
tanh()floatReturn the hyperbolic tangent of x as a float.Try it
asinh()floatReturn the inverse hyperbolic sine of x as a float.Try it
acosh()floatReturn the inverse hyperbolic cosine of x >= 1 as a float.Try it
atanh()floatReturn the inverse hyperbolic tangent of x in (-1, 1) as a float.Try it

Rounding, signs, and remainders

10 functions

Ceiling, floor, truncation, float absolute value, sign copying, modulo variants, splitting fractional parts, and NaN-ignoring min/max.

FunctionReturnsDescriptionTutorial
ceil()intReturn the ceiling of x, the smallest integer >= x.Try it
floor()intReturn the floor of x, the largest integer <= x.Try it
trunc()intTruncate x toward zero to an integer.Try it
fabs()floatReturn the absolute value of x as a float.Try it
copysign()floatReturn a float with the magnitude of x and sign of y.Try it
fmod()floatReturn floating-point remainder keeping the sign of x.Try it
remainder()floatReturn the IEEE 754 remainder of x with respect to y.Try it
modf()(float, float)Return the fractional and integer parts of x as floats.Try it
fmax()floatReturn the larger of x and y as a float, ignoring a single NaN.Try it
fmin()floatReturn the smaller of x and y as a float, ignoring a single NaN.Try it

Number theory, counting, and accurate sums

9 functions

Greatest common divisor, least common multiple, factorials, combinations, permutations, products, compensated sums, and fused multiply-add.

FunctionReturnsDescriptionTutorial
gcd()intReturn the greatest common divisor of integer arguments.Try it
lcm()intReturn the least common multiple of integer arguments (Python 3.9+).Try it
factorial()intReturn n! as an exact integer for non-negative integer n.Try it
comb()intReturn the number of ways to choose k items from n without order.Try it
perm()intReturn the number of ordered k-permutations from n items.Try it
prod()int or floatMultiply all numeric elements in an iterable starting from start=1.Try it
fsum()floatReturn an accurate floating-point sum of values in an iterable.Try it
sumprod()int or floatReturn the sum of products of values from two iterables (Python 3.12+).Try it
fma()floatReturn fused multiply-add (x * y) + z with a single rounding (Python 3.13+).Try it

Floating-point checks and special functions

15 functions

Tolerance comparison, finite/inf/NaN/normal/subnormal/signbit checks, binary float decomposition and ULPs, plus error and gamma functions.

FunctionReturnsDescriptionTutorial
isclose()boolReturn True if a and b are close within tolerances (Python 3.5+).Try it
isfinite()boolReturn True if x is neither an infinity nor a NaN.Try it
isinf()boolReturn True if x is positive or negative infinity.Try it
isnan()boolReturn True if x is a NaN (not a number).Try it
isnormal()boolReturn True if x is a finite, nonzero normal float.Try it
issubnormal()boolReturn True if x is a nonzero subnormal (denormal) float.Try it
signbit()boolReturn True if the IEEE 754 sign bit of x is set.Try it
frexp()(float, int)Return (mantissa, exponent) such that x == m * 2**e.Try it
ldexp()floatReturn x * (2**i) as a float, exact inverse of frexp().Try it
nextafter()floatReturn the next floating-point value after x toward y.Try it
ulp()floatReturn the value of the least significant bit of float x (Python 3.9+).Try it
erf()floatReturn the Gauss error function at x as a float.Try it
erfc()floatReturn the complementary error function 1 - erf(x) accurately.Try it
gamma()floatReturn the Gamma function at x as a float.Try it
lgamma()floatReturn natural log of the absolute value of Gamma(x).Try it

Frequently Asked Questions

It provides standard real-number math functions such as sqrt(), sin(), log(), floor(), gcd(), and comb(), plus constants like math.pi and math.e. Most floating-point functions wrap the C math library.
This index covers all 62 functions in the math module, from acos() to ulp(), grouped into seven categories, plus a constants table for pi, e, tau, inf, and nan.
No. Passing a complex number raises TypeError, and operations like math.sqrt(-1) raise ValueError. Use the standard library cmath module for complex math.
Trig functions such as sin(), cos(), and tan() take radians, and inverse functions such as asin() and atan2() return radians. Use math.radians() and math.degrees() to convert.
Read the Python math module hub for constants, domain errors, and float vs built-in differences, then open sqrt(), floor(), gcd(), or isclose() below.

Start with math.acos()

Open the first guide in the index and explore the math module.

acos() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful