NumPy Tutorial NumPy Statistics NumPy References

NumPy - deg2rad() function



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

Syntax

numpy.deg2rad(x, out=None)

Parameters

x Required. Specify array (array_like) containing elements as angles in degrees which need to be converted into radians.
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 radians value of each element of x.

Example:

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

import numpy as np

Arr = np.array([0, 30, 60, 90])

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

The output of the above code will be:

The radians value of angles:
[ 0.          0.52359878  1.04719755  1.57079633]

❮ NumPy - Functions