Python Función tan()
Descripción
tan()Devuelve el valor de la tangente de x radianes.
Sintaxis
La sintaxis del método tan() es la siguiente:
import math math.tan(x)
Nota:No se puede acceder a tan() directamente; es necesario 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.
Valor de retorno
Devuelve la tangente de x radianes, con un valor entre -1 y 1.
Ejemplos
Lo siguiente muestra un ejemplo del uso del método tan():
#!/usr/bin/python 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.142546543074 tan(-3) : 0.142546543074 tan(0) : 0.0 tan(math.pi) : -1.22460635382e-16 tan(math.pi/2) : 1.63317787284e+16 tan(math.pi/4) : 1.0Otras extensiones