Python math.tan() – Tangent Function

Python math.tan()

math.tan(x) function returns the tangent of x radians.

The return value lies in [-inf, inf].

Syntax

The syntax to call tan() function is

math.tan(x)

where

Parameter Required Description
x Yes A numeric value that represents angle in radians.

Examples

In the following example, we find the tangent of 0.5 radians using tan() function of math module.

Python Program

import math

x = 0.5 #radians
result = math.tan(x)
print('tan(x) :', result)
Run Code

Output

tan(x) : 0.5463024898437905

We can take angle in degrees and convert the degrees into radians using math.radians() function, and then find the tangent of this angle.

In the following program, we find the tangent of 60 degrees.

Python Program

import math

x = 60 #degrees
x = math.radians(x) #radians
result = math.tan(x)
print('tan(x) :', result)
Run Code

Output

tan(x) : 1.7320508075688767

Summary

In this Python Examples tutorial, we learned the syntax of, and examples for math.tan() function.

Related Tutorials

Privacy Policy Terms of Use

SitemapContact Us