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, ranging from -1 to 1.
Example
The following example returns the sine of a number:
Example
# Import the math package
import math
# Output the sine value
print (math.sin(0.00))
print (math.sin(-1.23))
print (math.sin(10))
print (math.sin(math.pi))
print (math.sin(math.pi/2))
import math
# Output the sine value
print (math.sin(0.00))
print (math.sin(-1.23))
print (math.sin(10))
print (math.sin(math.pi))
print (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
# Convert angle 30 to radians first, then calculate the sine value
print(math.sin(math.radians(30)))
# Convert angle 90 to radians first, then calculate the sine value
print(math.sin(math.radians(90)))
import math
# Convert angle 30 to radians first, then calculate the sine value
print(math.sin(math.radians(30)))
# Convert angle 90 to radians first, then calculate the sine value
print(math.sin(math.radians(90)))
Output result:
0.49999999999999994 1.0Other Extensions
Python math Module