Python math.sin() - Sine Function
Python math.sin()
math.sin(x) function returns the sine of x radians.
The return value lies in [-1, 1].
Syntax
The syntax to call sin() function is
math.sin(x)
where
Parameter | Required | Description |
---|---|---|
x | Yes | A numeric value that represents angle in radians. |
Examples
In the following example, we find the sine of 0.5 radians using sin() function of math module.
Python Program
import math
x = 0.5 #radians
result = math.sin(x)
print('sin(x) :', result)
Output
sin(x) : 0.479425538604203
We can take angle in degrees and convert the degrees into radians using math.radians() function, and then find the sine of this angle.
In the following program, we find the sine of 30 degrees.
Python Program
import math
x = 30 #degrees
x = math.radians(x) #radians
result = math.sin(x)
print('sin(x) :', result)
Output
sin(x) : 0.49999999999999994
Summary
In this Python Examples tutorial, we learned the syntax of, and examples for math.sin() function.