Python math - cos() Function
The Python math.cos() function returns trigonometric cosine of an angle (angle should be in radians). In the graph below, cos(x) vs x is plotted.
Syntax
math.cos(x)
Parameters
x |
Required. Specify the angle in radian. |
Return Value
Returns the trigonometric cosine of an angle.
Example:
In the example below, cos() function is used to find out the trigonometric cosine of an angle.
import math pi = math.pi print(math.cos(pi/6)) print(math.cos(pi/4)) print(math.cos(pi/3))
The output of the above code will be:
0.8660254037844387 0.7071067811865476 0.5000000000000001
❮ Python Math Module