Easy Tutorial
❮ Python Examples Python 2X 3X ❯

Python math.sin() Method

Python math Module

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 for the math.sin() method is as follows:

math.sin(x)

Parameter:

Return Value

Returns a float representing the sine of x, between -1 and 1.

Example

The following example returns the sine of a number:

# Import math package
import math

# Print sine values
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:

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:

# Import math package
import math

# Convert angle 30 to radians and calculate sine
print(math.sin(math.radians(30)))

# Convert angle 90 to radians and calculate sine
print(math.sin(math.radians(90)))

Output:

0.49999999999999994
1.0

Python math Module

❮ Python Examples Python 2X 3X ❯