Python Number sin() Method

Advertisements


Description

The method sin() returns the sine of x, in radians.

Syntax

Following is the syntax for sin() method:

sin(x)

Note: This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.

Parameters

  • x -- This must be a numeric value.

Return Value

This method returns a numeric value between -1 and 1, which represents the sine of the parameter x.

Example

The following example 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 we run above program, it produces following result:

sin(3) :  0.14112000806
sin(-3) :  -0.14112000806
sin(0) :  0.0
sin(math.pi) :  1.22460635382e-16
sin(math.pi/2) :  1



Advertisements
Advertisements