# Python – math.sin() function

## 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)) `

Output:

```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() `

Output:

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]

Last Updated on November 13, 2021 by admin

## Python – Intersection of two listsPython – Intersection of two lists

Python | Intersection of two lists Intersection of two list means we need to take

## Different ways to clear a list in PythonDifferent ways to clear a list in Python

Different ways to clear a list in Python   There are many ways of clearing

## Deque in PythonDeque in Python

Deque in Python Deque (Doubly Ended Queue) in Python is implemented using the module “collections“.

## Pandas Dataframe.to_dict()Pandas Dataframe.to_dict()

Pandas .to_dict() method is used to convert a dataframe into a dictionary of series or

## Python – Copy data from one excel sheet to anotherPython – Copy data from one excel sheet to another

Python | How to copy data from one excel sheet to another In this article,

json.loads() in Python JSON stands for JavaScript Object Notation. It is a lightweight data-interchange format that

## Replace NaN Values with Zeros in Pandas DataFrameReplace NaN Values with Zeros in Pandas DataFrame

Missing data in a Pandas DataFrame is commonly represented as NaN (Not a Number) values.

## Reading and Writing JSON to a File in PythonReading and Writing JSON to a File in Python

Reading and Writing JSON to a File in Python The full-form of JSON is JavaScript