Pythondex

Tutorial

Python Math Module

Python’s math module provides many useful functions for mathematical operations, like square roots, rounding, trigonometry, and constants.

Using Basic Math Functions

Rounding and Absolute Values

Power, Factorial, Min & Max

Trigonometry Functions

What You Learned

  • Use math.sqrt() to calculate square root.
  • math.ceil() rounds numbers up, math.floor() rounds down, round() rounds normally.
  • abs() gives the absolute value of a number.
  • math.pow() raises a number to a power, math.factorial() gives factorial.
  • min() and max() return the smallest and largest value.
  • Trigonometry functions: math.sin(), math.cos(), math.tan() take input in radians.
  • math.pi gives the value of π.