ExampleEdit & Run
#Use the math.tan function

#Import the math module
import math

#Call the math.tan function
print(math.tan(math.radians(30)))
copy
Output:
0.5773502691896257 [Finished in 0.010879258159548044s]

The math.tan() function returns the tangent of a value given in radians. This function takes a single parameter (x) and returns the tangent of the angle as a floating point number.

Syntax:
math.tan(x) 
copy

Where is the  angle(in radians), whose tangent we want.

The function returns the tangent of x.   

ExampleEdit & Run
import math

degree_angle = 20

radian_angle = math.radians(degree_angle)

print('The tangent of {} is {}'.format(degree_angle, math.tan(radian_angle)))
copy
Output:
The tangent of 20 is 0.36397023426620234 [Finished in 0.010464988183230162s]

The math.radians() function takes an angle in degrees and returns its value in radians.

ExampleEdit & Run
import math

print( math.tan( math.radians(30) ) )

print( math.tan( math.radians(45) ) )

print( math.tan( math.radians(50) ) )

print( math.tan( math.radians(80) ) )

print( math.tan( math.radians(120) ) )
copy
Output:
0.5773502691896257 0.9999999999999999 1.19175359259421 5.671281819617707 -1.7320508075688783 [Finished in 0.010188641957938671s]