Hit enter after type your search item

What is Python sin() function?

The sin() function:

  • Takes an argument (x = number)
  • and returns its sine in radians.
  • It’s the part of math module, so this function cannot be used directly.
  • You have to import the math module in your Python program – as shown in the examples below.
  • To get the result in degrees, you may use the radians() function along with sin() as shown in the example in the later section of this tutorial.

Syntax of sin() function

This is how the sin() function is used:


For example:


See the examples below for complete code.

What is sine function in Math? The sine is one of the most common trigonometric functions in math. The other two are cosine (or cos) and tangent (tan) functions. The sine function is based on the right-angled triangle. You may learn more about sine function here.

An example of sin() function

The example below shows using the sin() function to get the sine of a few numbers. We will get the sine in radians for 30, 45 and 60:

The result:

Python sine

In the above example, we used the shorthand for using the sin() function. This code will produce the same result:

The result:

The sine of 30 =  -0.9880316240928618

The sine of 45 =  0.8509035245341184

The sine of 60 =  -0.3048106211022167

How to get sine in degree?

You might be wondering why these answers are different than using a calculator for getting the sine of a number? This is because Python sin () function returns sine in radians.

The math module has another function radians() that you may use for converting the radians to degrees.

The example below uses the same values as in the above examples and also use the radians() function for converting the returned result by sin() function and get the sine values in degree:

The output:

The sine of 30 in degree =  0.49999999999999994

The sine of 45 in degree =  0.7071067811865475

The sine of 60 in degree =  0.8660254037844386

Rounding the result example

The example below uses three functions together; sin(), radians() and round(). The round function will round the result returned by radians() function to single precision. See the code and output:

The output of the above code is:

The sine of 30 in degree with single precision =  0.5

The sine of 45 in degree with single precision =  0.7

The sine of 60 in degree with single precision =  0.9

Learn more about the round function in its tutorial: Python round function.

This div height required for enabling the sticky sidebar