Facebook Page Twitter Page LinkedIn Page
× NumPy Tutorial NumPy Resources


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

Syntax

numpy.radians(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 below example, numpy radians() 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.radians(Arr))

The output of the above code will be:

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

❮ NumPy - Functions

5