Python Number sin() Method


Contents

Description

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.

Syntax

Here is the syntax for sin() method:

sin(x)

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.

Parameters

  • x − This should be a numeric value.

Return 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.

Example

The example below shows the usage of sin() method.

#!/usr/bin/python
import math

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.



Navigation
Tutorial
Tutorial
Tutorial