math.sin() method is a library method of math module, it is used to get the sine of the number in radians, it accepts a number returns the cosine of the given number in radians.
math.sin(x)
float
– it returns a float value that is the sine value of the number x radians.a = 0.278
# function call
print(math.sin(a))
Output
0.27443298625778634
Write a program to show the working of 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))
Output
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
Write a program to pass the value out of range from the sin() function and display the output.
import math
a = 'Hello'
print(math.cos(a))
Output
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 which represents the ratio between hypotenuse and opposite.
Thanks for reading !
#python #programming