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()andmax()return the smallest and largest value.- Trigonometry functions:
math.sin(),math.cos(),math.tan()take input in radians. math.pigives the value of π.