Python 3 - Méthode Number tan ()

La description

le tan() La méthode renvoie la tangente de x radians.

Syntaxe

Voici la syntaxe pour tan() méthode -

tan(x)

Note - Cette fonction n'est pas accessible directement, nous devons donc importer un module mathématique, puis nous devons appeler cette fonction en utilisant un objet statique mathématique.

Paramètres

x - Cela doit être une valeur numérique.

Valeur de retour

Cette méthode renvoie une valeur numérique comprise entre -1 et 1, qui représente la tangente du paramètre x.

Exemple

L'exemple suivant montre l'utilisation de la méthode tan ().

#!/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))

Production

Lorsque nous exécutons le programme ci-dessus, il produit le résultat suivant -

(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