Python3 Función tan()

Python3 数字Números en Python3


Descripción

tan()La función esmathuna función en el módulo, utilizada para calcular el valor tangente de un ángulo.

Para usar la función tan(), primero debe importar el módulo math, y luego llamar a lamath.tan()función, pasando un ángulo (en radianes) como parámetro.

Sintaxis

La sintaxis del método tan() es la siguiente:

import math

math.tan(x)

Nota:tan() no se puede acceder directamente, necesita importar el módulo math, y luego llamar a este método a través del objeto estático math.


Parámetros

  • x -- un valor numérico, es un ángulo.

Valor de retorno

Devuelve el valor tangente de x radianes, el resultado está en el rango de -math.pi/2 a math.pi/2.


Ejemplo

A continuación se muestra un ejemplo del uso del método tan():

Ejemplo (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))

El resultado de ejecutar el ejemplo anterior es:

(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 数字Números en Python3

Otras extensiones