Open links in new tab
  1. math — Mathematical functions — Python 3.14.3 documentation

  1. The math module in Python provides a rich set of mathematical functions and constants for performing number theory, floating-point arithmetic, trigonometry, logarithmic, and special operations. It operates on real numbers only — for complex numbers, use the cmath module.

    Key constants include:

    • math.pi → π (3.14159…)

    • math.e → Euler’s number (2.71828…)

    • math.tau → τ = 2π

    • math.inf → Positive infinity

    • math.nan → Not-a-Number

    Example usage:

    import math

    # Constants
    print(math.pi) # 3.141592653589793
    print(math.e) # 2.718281828459045

    # Number theory
    print(math.factorial(5)) # 120
    print(math.gcd(48, 18)) # 6

    # Floating point operations
    print(math.ceil(2.3)) # 3
    print(math.floor(2.9)) # 2
    print(math.fabs(-7.5)) # 7.5

    # Power & logarithms
    print(math.sqrt(16)) # 4.0
    print(math.pow(2, 3)) # 8.0
    print(math.log(100, 10)) # 2.0

    # Trigonometry
    angle = math.radians(30)
    print(math.sin(angle)) # 0.5
    print(math.cos(angle)) # 0.8660254037844387

    # Special functions
    print(math.gamma(6)) # 120.0
    print(math.isfinite(5.0)) # True
    Copied!
    Feedback
  2. Python math Module - W3Schools

    50 rows · Python has a built-in module that you can use for mathematical tasks. The math module has …

  3. Python Math Module - GeeksforGeeks

    Jul 26, 2025 · The math module in Python is a built-in library that contains a collection of mathematical functions and constants. It is commonly used to perform standard math operations such as rounding, …

  4. math | Python Standard Library – Real Python

    In this step-by-step tutorial, you’ll learn all about Python’s math module for higher-level mathematical functions. Whether you’re working on a scientific project, a …

  5. Python Math Module Guide (22 Examples and 18 Functions)

    May 10, 2022 · In this tutorial, we'll explore the common constants and functions of the Python `math` module — and how to use them.

    • LOI
      www.loi.nl › Opleidingen › Python
      About our ads

      Training Python LOI | Deeltijd Python thuisstudie

      SponsoredBinnen 3 maanden specialist in Python worden? Kies voor Programmeren in Python van LOI. Bekijk het aanbod Python opleidingen van LOI. Geen vooropleiding vereist!