Math Module

Published Jul 30, 2021Updated Sep 9, 2021
Contribute to Docs

Python has a built-in math module that we can use for mathematical tasks. This module provides access to the mathematical functions defined by the C standard.

The following functions are provided by this module. Except when explicitly noted otherwise, all return values are floats.

Math Module

math.ceil()
Takes in a numeric data type and rounds the value up to the nearest integer.
math.cos()
Returns the cosine of an angle.
math.exp()
Returns e raised to the power of x.
math.log()
Returns the natural logarithm of a number or the logarithm of a number to the given base.
math.pow()
Returns the float value of x raised to the power of y.
math.sin()
Returns the sine of input numeric x, measured in radian value.
math.sqrt()
Returns the square root of numeric input x.
math.tan()
Returns the tangent of input numeric x, measured in radians.

All contributors

Looking to contribute?

Learn Python on Codecademy