Python Trigonometric Functions
Overview
In this tutorial, we learn about Python trigonometric functions. Python language provides trigonometric functions through its math module. We can import the math module to use the functions in the program.
Python Trigonometric Functions
Python language provides a comprehensive set of trigonometric functions as follows:
Python Trigonometric function |
Description |
sin(x) | This function returns the sine of x, where x is given in radians. |
cos(x) | This function returns the cosine of x, where x is given in radians. |
tan(x) | This function returns the tangent of x, where x is given in radians. |
asin(x) | This function returns the arcsine of x, where x is given in radians. |
acos(x) | This function returns the arccosine of x, where x is given in radians. |
atan(x) | This function returns the arctangent of x, where x is given in radians. |
atan2(y,x) | This function returns the arctangent of y/x in radians. Unlike atan(), this function uses the signs of y and x to determine the quadrant of the angle. |
hypot(x, y) | This function computes the Euclidean distance, i.e.,
This is the length of the vector from the origin to point (x, y). |
degrees(x) | This function converts the angle x from radians to degrees. |
radians(x) | This function converts an angle x from degrees to radians. |
These functions are essential in various fields like physics, engineering, and computer graphics, etc.
Example
# Python program trigonometric functions # Python Tutorials - www.TestingDocs.com import math x = 60 # x in degrees y = math.sin(math.radians(x)) # sin(x) x is in radians print('sin({0})={1}'.format(x, y))
—
Python Tutorials
Python Tutorial on this website can be found at:
https://www.testingdocs.com/python-tutorials/
More information on Python is available at the official website: