Python | math.sin() function
In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.sin() function returns the sine of value passed as argument. The value passed in this function should be in radians.
Syntax: math.sin(x)
Parameter:
x : value to be passed to sin()
Returns: Returns the sine of value passed as argument
Code #1:
# Python code to demonstrate the working of sin() # importing "math" for mathematical operations import math a = math.pi / 6 # returning the value of sine of pi / 6 print ("The value of sine of pi / 6 is : ", end ="") print (math.sin(a)) |
The value of sine of pi/6 is : 0.49999999999999994
Code #2:
# Python program showing # Graphical representation of # sin() function import math import matplotlib.pyplot as plt in_array = [-3.14159265, -2.57039399, -0.28559933, 0.28559933, 2.57039399, 3.14159265] out_array = [] for i in range(len(in_array)): out_array.append(math.sin(in_array[i])) i += 1 print("in_array : ", in_array) print("\nout_array : ", out_array) # red for numpy.sin() plt.plot(in_array, out_array, color = 'red', marker = "o") plt.title("math.sin()") plt.xlabel("X") plt.ylabel("Y") plt.show() |
in_array : [-3.14159265, -2.57039399, -0.28559933, 0.28559933, 2.57039399, 3.14159265]
out_array : [-3.5897930298416118e-09, -0.5406408168673427, -0.2817325547837714, 0.2817325547837714, 0.5406408168673427, 3.5897930298416118e-09]

Recommended Posts:
- id() function in Python
- sum() function in Python
- Python | cmp() function
- Python | now() function
- Python | hex() function
- Python map() function
- Python | dir() function
- Help function in Python
- Python | oct() function
- Python | int() function
- Python | How to get function name ?
- ord() function in Python
- round() function in Python
- Python | tuple() Function
- Python | frexp() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



