Python Fonction tan()

Python 数字Nombres en Python


Description

tan()Renvoie la tangente de x radians.


Syntaxe

Voici la syntaxe de la méthode tan() :

import math

math.tan(x)

Remarque :tan() n'est pas directement accessible ; vous devez importer le module math, puis appeler la méthode via l'objet statique math.


Parameters

  • x -- Une valeur numérique.

Valeur de retour

Renvoie la tangente de x radians, avec une valeur comprise entre -1 et 1.


Exemples

Ce qui suit montre un exemple d'utilisation de la méthode 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)

Après avoir exécuté l'exemple ci-dessus, la sortie est :

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.0

Python 数字Nombres en Python

Autres extensions