The sin() function in the Python math module is supposed to return the sine value that has been passed as an argument. The value passed in this specific function must be in radians. In Python, the mathematical module consists of several mathematical operations that can be performed easily making use of the module.
Here is the syntax for sin() method:
Note − One cannot access this function directly, so it is required to import the math module in Python and then we are supposed to call this function making use of the math static object.
- x − This should be a numeric value.
This method in Python math number returns the numeric value that lies between -1 and 1, which further represents the sine of the parameter x.
The example below shows the usage of sin() method.
print "sin(3) : ", math.sin(3)
print "sin(-3) : ", math.sin(-3)
print "sin(0) : ", math.sin(0)
print "sin(math.pi) : ", math.sin(math.pi)
print "sin(math.pi/2) : ", math.sin(math.pi/2)
When the above program is run, it produces following result:
sin(3) : 0.14112000806
sin(-3) : -0.14112000806
sin(0) : 0.0
sin(math.pi) : 1.22464679915e-16
sin(math.pi/2) : 1.0
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.