Latest Code Tutorials

Python sin: How to Use Math.sin() Function

In Python, the math module contains several mathematical operations, which can be easily performed using the module. The math.sin() function returns a sine of the value passed as an argument. The value given in the sin() function should be in radians.

Python sin()

Python sin() is a built-in math function that is used to find the sine value of the parameter passed in radians. The sin() function accepts x as a parameter and returns the sine value of x in radians.

We can use a math module by importing it. The syntax would be import math; after importing, we call the sin() function using a static object.



Here var is the variable of which sine we have to find.


It takes one parameter var, which takes values of the numeric datatype and throws TypeError if an argument of any other data type is passed.

Return Value

It returns the sine value of the number in the float datatype.

See the following example.

import math

var = 0.36

Example programs on sin() method in Python

Example 1: Write a program to show the working of the sin() method in Python.

import math

a1 = 0.36
b1 = 1
c1 = -1
d1 = -0.36

print("Value for parameter ", a1, " is ", math.sin(a1))
print("Value for parameter ", b1, " is ", math.sin(b1))
print("Value for parameter ", c1, " is ", math.sin(c1))
print("Value for parameter ", d1, " is ", math.sin(d1))


Value for parameter  0.36  is  0.35227423327508994
Value for parameter  1  is  0.8414709848078965
Value for parameter  -1  is  -0.8414709848078965
Value for parameter  -0.36  is  -0.35227423327508994

In this example, we have seen that by passing a valid parameter different for different examples, we get the desired sin() method solution, which is the sine value of the parameter.

Example 2: Write a program to pass the value out of range from the sin() function and display the output.

See the following example.

import math

a = 'Hello'


For output:   TypeError: must be real number, not str

In this example, we’ve seen that passing a parameter, which is not a real number, throws a TypeError.


Python sin() function is used to find the sine of a given argument in radians, where sine is a trigonometric function that represents the ratio between hypotenuse and opposite.

See also

Python hypot()

Python atan()

Python atan2()

Python acos()

Python asin()

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.