Python math.sin() Method
Python math.sin(x) Returns the sine of x radians.
To get the sine of a specified angle, you must first convert it to radians using the math.radians() method.
Python version: 1.4
Syntax
The syntax of the math.sin() method is as follows:
math.sin(x)
Parameter Description:
- x -- required, a number. If x is not a number, a TypeError is returned.
Return Value
Returns a floating-point number representing the sine of x, between -1 and 1.
Example
The following example returns the sine of numbers:
Example
Import the math package
import
math
Output the sine values
(
math
.
sin
(
0.00
)
)
(
math
.
sin
(
1.23
)
)
(
math
.
sin
(
10
)
)
(
math
.
sin
(
math
.
pi
)
)
(
math
.
sin
(
math
.
pi
/
2
)
)
Output result:
0.0
-0.9424888019316975
-0.5440211108893699
1.2246467991473532e-16
1.0
To get the sine of a specified angle, you must first convert it to radians using the math.radians() method:
Example
Import the math package
import
math
An angle of 30 is converted to radians before computing the sine
(
math
.
sin
(
math
.
radians
(
30
)
)
)
An angle of 90 is converted to radians before computing the sine
(
math
.
sin
(
math
.
radians
(
90
)
)
)
Output result:
0.49999999999999994
1.0
Python math Module