Common Math Functions in Python
The Python math module provides useful mathematical functions and constants. Here is a
list of the most common math functions with examples and outputs.
Function Example Output Use
[Link](x) [Link](16) 4.0 Square root
[Link](x,y) [Link](2,3) 8.0 Power (same as
x**y)
[Link](x) [Link](1) 2.718... Exponential
function (e^x)
[Link](x) [Link](10) 2.302... Natural log (base e)
math.log10(x) math.log10(100) 2.0 Logarithm base 10
math.log2(x) math.log2(8) 3.0 Logarithm base 2
[Link](x) [Link](5) 120 Factorial
[Link](a,b) [Link](24,36) 12 Greatest Common
Divisor
[Link](a,b) [Link](4,6) 12 Least Common
Multiple (Python
3.9+)
[Link](x) [Link](3.9) 3 Rounds down
[Link](x) [Link](3.1) 4 Rounds up
[Link](x) [Link](4.7) 4 Truncates decimal
part
[Link](x) [Link](math. 180.0 Radians → Degrees
pi)
[Link](x) [Link](180) 3.1415... Degrees → Radians
[Link](x) [Link]([Link]/2) 1.0 Sine (x in radians)
[Link](x) [Link](0) 1.0 Cosine
[Link](x) [Link]([Link]/ 1.0 Tangent
4)
[Link](x) [Link](1) 1.5707... Inverse sine
[Link](x) [Link](0) 1.5707... Inverse cosine
[Link](x) [Link](1) 0.785... Inverse tangent
Constants in math
Constant Value
[Link] 3.141592653589793
math.e 2.718281828459045
[Link] 6.283185307179586 (2π)
[Link] Infinity
[Link] Not a Number