The math.tan() method returns the tangent of a number in radians.
Syntax
import math
math.tan(x)
Parameters
x(required): It takes numeric datatype.
Return Value
Returns tangent of a number in the float datatype.
It throws a TypeError if the argument provided is not a number.
Visual Representation
Example 1: How to Use math.tan() Method
import math
print (math.tan(0))
print (math.tan(5))
print (math.tan(-5))
print (math.tan(12.35))
Output
0.0
-3.380515006246585
3.380515006246585
-0.21981161980223166
Example 2: TypeError
import math
print(math.tan('app'))
Output
TypeError: must be real number, not str
Example 3: Calculating Tangents of Angles
import math
print(math.tan(math.pi / 4))
print(math.tan(math.pi / 6))
Output
0.9999999999999999
0.5773502691896256