Change language

# Python | math.sin () function

In Python, a math module contains a number of math operations that can be easily accomplished using the module. `math.sin() ` returns the sine of the value passed as an argument. The value passed to this function must 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 how sin () works `   ` # import & quot; math & quot; for math operations ` ` import ` ` math `   ` a ` ` = ` ` math.pi ` ` / ` ` 6 `   ` # returns sine pi / 6 ` ` print ` ` (` ` "The value of sine of pi / 6 is:" ` `, end ` ` = ` ` "") ` ` print ` ` (math.sin (a)) `

Output:

` The value of sine of pi / 6 is: 0.49999999999999994 `

Code # 2:

 ` # Show Python program ` ` # Graphical view ` ` # 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 ` ` (` ` "out_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 () `

Exit:

in_array: [-3.14159265, -2.57039399, -0.2855993 3, 0.28559933, 2.57039399, 3.14159265]

out_array: [-3.5897930298416118e-09, -0.5406408168673427, -0.2817325547837714, 0.2817325547837714, 0.540640816830e2984]

## Shop

Learn programming in R: courses

\$FREE

Best Python online courses for 2022

\$FREE

Best laptop for Fortnite

\$399+

Best laptop for Excel

\$

Best laptop for Solidworks

\$399+

Best laptop for Roblox

\$399+

Best computer for crypto mining

\$499+

Best laptop for Sims 4

\$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries