Python Number Atan2() Method



The atan2() method in Python numbers is a library method of its math module, which is used for getting the arc tangent value of y/x (i.e. atany/x). It is known to accept two numbers and then returns an arc tangent of y/x in radians.


Here is the syntax for atan2() method:

atan2(y, x)

Note - One cannot access this function directly, so it is required to import the math module in Python and then we are supposed to call this function making use of the math static object.


  • y - This should be a numeric value.
  • x - This should be a numeric value.

Return Value

This method in the Python math module returns atan(y / x), in radians.


The example below shows the usage of atan2() method.

import math

print "atan2(-0.50,-0.50) : ",  math.atan2(-0.50,-0.50)
print "atan2(0.50,0.50) : ",  math.atan2(0.50,0.50)
print "atan2(5,5) : ",  math.atan2(5,5)
print "atan2(-10,10) : ",  math.atan2(-10,10)
print "atan2(10,20) : ",  math.atan2(10,20)

When the above program is run, it produces the following result:

atan2(-0.50,-0.50) :  -2.35619449019
atan2(0.50,0.50) :  0.785398163397
atan2(5,5) :  0.785398163397
atan2(-10,10) :  -0.785398163397
atan2(10,20) :  0.463647609001

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.