Hello Readers! Welcome to another tutorial on NumPy Functions. In this tutorial, we will understand three important functions i.e. numpy.degrees(), numpy.deg2rad(), numpy.rad2deg() and numpy.radians() in detail.

So, let’s get started.

## 1. numpy.degrees()

`numpy.degrees()` is a function of the NumPy Library that converts the angle from radians to degrees.

Syntax: `numpy.degrees(input)` where input can be a single angle in radians or a NumPy array of angles in radians.

### Working with numpy.degrees()

Let’s try out some examples for better understanding.

#### Using numpy.degrees() with a single angle as an input

```import numpy as np

# Converting pi/6 radians to equivalent angle in degrees

# Converting pi/4 radians to equivalent angle in degrees

# Converting pi/3 radians to equivalent angle in degrees

# Converting pi/2 radians to equivalent angle in degrees

# Converting pi radians to equivalent angle in degrees

```

Output

```PI/6 radians is  29.999999999999996 degrees

```

The above snippet is pretty much clear where a single angle(in radians) is passed as an argument to the `np.degrees()` function.

#### Using numpy.degrees() with the NumPy Array

```import numpy as np

a = np.array((np.pi/3 , np.pi/2 , np.pi/4 , np.pi))
b = np.degrees(a)

print("Corresponding angles in degrees: \n",b)
```

Output

```Angles in radians:
[1.04719755 1.57079633 0.78539816 3.14159265]
Corresponding angles in degrees:
[ 60.  90.  45. 180.]
```

A NumPy Array is created and assigned to the variable `a` in the above snippet. All the angles are in radians in this array, which is passed to the np.degrees() function.

`numpy.deg2rad()` is a mathematical function that converts the angle in degrees to angles in radians.

Syntax: `numpy.deg2rad(input)` where input can be a single angle in degrees or a NumPy array of angles in degrees.

Let’s try out a few degree 2 radians examples now.

#### Using numpy.deg2rad() with a single angle as an input

```import numpy as np

```

Output

```30 degrees is equal to  0.5235987755982988 radians

45 degrees is equal to  0.7853981633974483 radians

60 degrees is equal to  1.0471975511965976 radians

90 degrees is equal to  1.5707963267948966 radians

360 degrees is equal to  6.283185307179586 radians
```

#### Using numpy.deg2rad() with a NumPy Array

```import numpy as np

a = np.array((30 , 45 , 60 , 90 , 180 , 270 , 360))

print("Angles in Degrees :\n",a)

```

Output

```Angles in Degrees :
[ 30  45  60  90 180 270 360]
[0.52359878 0.78539816 1.04719755 1.57079633 3.14159265 4.71238898
6.28318531]
```

`numpy.rad2deg()` function of the NumPy library is equivalent to numpy.degrees() function. It converts the value of the angle in radians to the angle in degrees.

Syntax: `numpy.rad2deg(input)` where input can be a single angle in radians or a NumPy array of angles in radians.

Let’s try some examples to understand it better.

Now let’s move to radians to degrees function of Numpy.

#### Using numpy.rad2deg() with a NumPy Array

```import numpy as np

a = np.array((-np.pi , np.pi/2 , np.pi/3 , np.pi/4 , np.pi))

print("Angles in Degrees:\n",b)
```

Output

```Angles in Radians:
[-3.14159265  1.57079633  1.04719755  0.78539816  3.14159265]
Angles in Degrees:
[-180.   90.   60.   45.  180.]
```

`numpy.radians()` is also one of the mathematical functions that convert the angles from degrees to radians.

Syntax: `numpy.radians(input)` where input can be a single angle or a NumPy array of angles in degrees.

Let’s finally take a look at the radians function of numpy.

#### Using numpy.radians() with a NumPy Array

```import numpy as np

a = np.array((60 , 90 , 45 , 180))

print("Angles in degrees: \n",a)

```Angles in degrees:
That was all about NumPy degrees(), deg2rad(), rad2deg() and radians() functions. These functions are really simple to use and easy to understand. Do read this article twice and practice the codes along with reading the article. There is a task for you all, you have to use the `numpy.rad2deg(``) `and `numpy.radians()` function with single inputs.