Introduction to Python: An Example of trigonometric function tan (), pythontan
Description
Tan () returns the sine of x radians.
Syntax
The syntax of the tan () method is as follows:
import mathmath.tan(x)
Note: tan () cannot be accessed directly. You need to import the math module and call this method through the math static object.
Parameters
X -- a value.
Return Value
Returns the sine of x radians. The value ranges from-1 to 1.
Instance
The following example shows how to use the tan () method:
#!/usr/bin/pythonimport mathprint "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)
The output result is as follows:
tan(3) : -0.142546543074tan(-3) : 0.142546543074tan(0) : 0.0tan(math.pi) : -1.22460635382e-16tan(math.pi/2) : 1.63317787284e+16tan(math.pi/4) : 1.0
Summary
The above is all the details about the introduction to the Python trigonometric function tan () function instance. I hope to help you. If you are interested, you can continue to refer to this site: Python introduction to trigonometric function sin () function examples, Python introduction to trigonometric function atan2 () function details, a simple understanding of several functions in Python, etc, if you have any questions, you can leave a message at any time. The editor will reply to you in a timely manner. Thank you for your support!