Easy Tutorial
❮ Home Python Func Input ❯

Python3 tan() Function

Python3 Numbers


Description

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


Syntax

Here is the syntax for the tan() method:

import math

math.tan(x)

Note: The tan() function cannot be accessed directly; it is necessary to import the math module and then call this function using the math static object.


Parameters


Return Value

Returns the tangent of x radians, with the value ranging from -1 to 1.


Example

Below are examples of using the tan() method:

Example (Python 3.0+)

#!/usr/bin/python3
import math

print("(tan(3) : ", math.tan(3))
print("tan(-3) : ", math.tan(-3))
print("tan(0) : ", math.tan(0))
print("tan(math.pi) : ", math.tan(math.pi))
print("tan(math.pi/2) : ", math.tan(math.pi/2))
print("tan(math.pi/4) : ", math.tan(math.pi/4))

The output of the above examples is:

(tan(3) :  -0.1425465430742778
tan(-3) :  0.1425465430742778
tan(0) :  0.0
tan(math.pi) :  -1.2246467991473532e-16
tan(math.pi/2) :  1.633123935319537e+16
tan(math.pi/4) :  0.9999999999999999

Python3 Numbers

❮ Home Python Func Input ❯