Python | math.tan() Funktion
In Python enthält das Mathematikmodul eine Reihe von mathematischen Operationen, die mit dem Modul problemlos ausgeführt werden können. math.tan()
Die Funktion gibt die Tangente des als Argument übergebenen Werts zurück. Der in dieser Funktion übergebene Wert sollte im Bogenmaß angegeben werden.
Syntax: math.tan (x)
Parameter:
x: Wert, der an tan() übergeben werden sollRückgabe: Gibt die Tangente des als Argument übergebenen Werts zurück
Code # 1:
import
math
a
=
math.pi
/
6
(
"The value of tangent of pi / 6 is : "
, end
=
"")
(math.tan(a))
Code # 2:
import
math
import
numpy as np
import
matplotlib.pyplot as plt
in_array
=
np.linspace(
0
, np.pi,
10
)
out_array
=
[]
for
i
in
range
(
len
(in_array)):
out_array.append(math.tan(in_array[i]))
i
+
=
1
(
"in_array : "
, in_array)
(
"\nout_array : "
, out_array)
plt.plot(in_array, out_array, color
=
'red'
, marker
=
"o"
)
plt.title(
"math.tan()"
)
plt.xlabel(
"X"
)
plt.ylabel(
"Y"
)
plt.show()
Ausgabe:
in_array: [0. 0,34906585 0,6981317 1,04719755 1,3962634 1,74532925
2,0943951 2,44346095 2,7925268 3,14159265]out_array: [0,0, 0,36397023426620234, 0,8390996311772799, 1,7320508075688767, 5,671281819617707, -5,671281819617711, -1,7320508075688783, -0,8390996311772804, -0,363970234236