Latest web development tutorials

Python3 sin () function

Python3 digital Python3 digital


description

sin () returns the sine of x radians.


grammar

The following is the syntax sin () method:

import math

math.sin(x)

Note: sin () is not directly accessible, you need to import math module, and then call the method by math static objects.


parameter

  • x - a value.

return value

Returns the sine of x radians values ​​between -1 and 1.


Examples

The following shows an example of using sin () method:

#!/usr/bin/python3
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))

After running the above example output is:

sin(3) :  0.1411200080598672
sin(-3) :  -0.1411200080598672
sin(0) :  0.0
sin(math.pi) :  1.2246467991473532e-16
sin(math.pi/2) :  1.0

Python3 digital Python3 digital