Python atan: How to Use Math.atan() Method

Python atan() is an inbuilt method defined under the math module that is used to find the arctan of var( var is a variable that can take any number value) in radians. We need to import math module. The syntax for it would be import math; after importing, we use to call the atan() function using the static object.

Python atan()

Python number method atan() returns the arctangent of x in radians. We can calculate the inverse of tan in Python using the math.atan() method. An inverse of tan or tangent is also called an arctan or arctangent.




The atan() function takes one parameter var, which takes values of any number type. Any other data type is not acceptable. If any other data type is passed as a parameter, it throws a type error.

Return Value

It returns the arc tan value of the number in the float datatype.

See the following example.


import math

var = 0.36



Example programs on atan() method in Python

Example 1: Write a program to show the working of the atan() method in Python.
import math
a1 = 0.36
b1 = 1
c1 = -1
d1 = -0.36

print("Value for parameter ", a1, " is ", math.atan(a1))
print("Value for parameter ", b1, " is ", math.atan(b1))
print("Value for parameter ", c1, " is ", math.atan(c1))
print("Value for parameter ", d1, " is ", math.atan(d1))
Value for parameter  0.36  is  0.3455555805817121
Value for parameter  1  is  0.7853981633974483
Value for parameter  -1  is  -0.7853981633974483
Value for parameter  -0.36  is  -0.3455555805817121

In this example, we have seen that by passing a valid parameter which is different for different examples, we get the desired atan() method solution, which is an arc of the tangent.

Example 2: Write a program to pass the value of any other datatype in the atan() function and display the output.
import math
a1 = 'a'

print("Value for parameter ", a1, " is ", math.atan(a1))
TypeError: must be a real number, not str

In this example, we tried to pass a parameter which is not of real number type; hence it returned a type error stating that the number must be real.


Arctan of x can be defined as an inverse of the tangent function of x where x is the real number (x∈).” It is the angle between −π/2 and +π/2 radians (or between −90° and +90°) whose tan is x.

See Also

Python acos()

Python asin()

Python log(2)

Python log(x, base)

Python log1p(x)

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.