NumPy Tutorial NumPy Statistics NumPy References

NumPy - rad2deg() function



The NumPy rad2deg() function is used to convert angles from radians to degrees.

Syntax

numpy.rad2deg(x, out=None)

Parameters

x Required. Specify array (array_like) containing elements as angles in radians which need to be converted into degrees.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns corresponding degrees value of each element of x.

Example:

In the example below, numpy rad2deg() function is used to convert each element (representing angles in radians) of array Arr into degrees.

import numpy as np

Arr = np.array([0, np.pi/3, np.pi/6, np.pi/2])

#converting the angles in degrees
print("The degrees value of angles:")
print(np.rad2deg(Arr))

The output of the above code will be:

The degrees value of angles:
[  0.  60.  30.  90.]

❮ NumPy - Functions

5