Python 3 – Number atan() Method
The Python 3 atan() method belongs to the math module and takes one parameter as input. This method returns the inverse tangent of a given number in radians.
Here is the syntax of the atan() method:
import math
math.atan(number)
The parameter ‘number’ is the value whose inverse tangent (in radians) is to be determined.
The atan() method returns the inverse tangent value in radians.
Example:
import math
x = 0.5
y = math.atan(x)
print("Inverse tangent of {} is: {}".format(x, y))
Output:
Inverse tangent of 0.5 is: 0.4636476090008061
The method can also be used to obtain the inverse tangent in degrees. Simply convert the radians to degrees as shown in the following example:
Example:
import math
x = 0.5
y = math.atan(x)
z = math.degrees(y)
print("Inverse tangent of {} degrees is: {}".format(x, z))
Output:
Inverse tangent of 0.5 radians is: 26.56505117707799 degrees
In the above code snippet, we have used the math.degrees() method to convert the radians to degrees.
Conclusion
In this article, we have discussed the Python 3 atan() method. We have seen how this method returns the inverse tangent value of a given number in radians. We have also looked at how to obtain the inverse tangent value in degrees. The atan() method can be helpful in finding the angle of incidence, angle of refraction and much more.