Draw a right triangle using sine and cosine as shown in the illustration below:

math.sin(x) returns the sine of x radians.

math.cos(x) return the cosine of x radians.

math.radians(x) converts x degrees into radians.

For example, to get the sin of 2 radians:

>>> import math
>>> math.sin(2)

To get the cos of 2 radians:

>>> import math
>>> math.cos(2)

 To convert degrees to radians, use math.radians(), like this:

>>> import math
>>> math.radians(40)

Note: math.radians(180) == math.pi, which is stored in Python as , accurate to 15 digits or so.

You can find the cos or sin of u degrees by first converting u to radians, then taking the cos or sin of the result:

>>> import math
>>> x = math.cos(math.radians(u))
>>> y = math.sin(math.radians(u))

What are the sine, cosine, and tangent functions?

If you're not familiar with the sine, cosine, and tangent functions, see the video on trigonometric ratios below.

What are radians?

Watch the video below to find out.

1 2 3 4 5 6 7 8 9 10 11 12