Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.sin() Method

Python math.sin() Method

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

math.sin(x)

Parameter Description:

Return Value

Returns a floating-point number representing the sine of x, between -1 and 1.

Example

The following example returns the sine of numbers:

Example

Import the math package

import

math

Output the 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 result:


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:

Example

Import the math package

import

math

An angle of 30 is converted to radians before computing the sine

print

(

math

.

sin

(

math

.

radians

(

30

)

)

)

An angle of 90 is converted to radians before computing the sine

print

(

math

.

sin

(

math

.

radians

(

90

)

)

)

Output result:


0.49999999999999994
1.0

Python math Module Python math Module