Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries

The Python math.atan2() function is used to return the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). The return value will be in the range -𝜋 through 𝜋.


math.atan2(y, x)


y Required. Specify the ordinate coordinate.
x Required. Specify the abscissa coordinate.

Return Value

Returns theta of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.


In the below example, atan2() function is used to calculate the theta of a point.

import math

print(math.atan2(10, 10))
print(math.atan2(20, 10))
print(math.atan2(-20, 10))

The output of the above code will be:


❮ Python Math Module