YouTip LogoYouTip

Python3 Func Number Tan

# Python3.x Python3 tan() Function [![Image 3: Python3 Numbers](#) Python3 Numbers](#) * * * ## Description The `tan()` function is a function in the `math` module used to calculate the tangent of an angle. To use the `tan()` function, you first need to import the `math` module, then call the `math.tan()` function, passing an angle (in radians) as an argument. ## Syntax Here is the syntax for the `tan()` method: import math math.tan(x) **Note:** `tan()` cannot be accessed directly; you need to import the `math` module and then call the method via the `math` static object. * * * ## Parameters * x -- A numeric value representing an angle. * * * ## Return Value Returns the tangent of x radians. The result is in the range between `-math.pi/2` and `math.pi/2`. * * * ## Examples The following examples demonstrate the use of 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 example after running 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 [![Image 4: Python3 Numbers](#) Python3 Numbers](#)
← Python3 Func Number RadiansPython3 Func Number Tan β†’