Posted on

The Python language comes in handy for every mathematician. The built-in math module has a large arsenal of tools for mathematical calculations. This article will talk about math in Python, namely:

mathematical constants; rounding methods; degree and division arithmetic operators; angles and trigonometric functions; comparing floating point numbers, modulus, and repeating items in a list.

Math Constants
Python provides use of mathematical constants found in the math module, such as pi, Euler number, empty nan value, infinity.

Rounding
Sometimes you don’t want to look at all the digits after the decimal point, or you don’t want high precision.

To round to kth decimal place, we use the round function, which is built into Python and takes the number itself and the number of digits as arguments.

Trigonometry
In Python, you can work with angles, radians, cosines, sines, tangents, etc. The conversion of radians to degrees is done through the math.degrees function.