What is the degrees function in Numpy?
The degrees function is used to convert radian values to degrees. It comes as a part of Numpy, which is a library of the high-level coding language Python.
Syntax
numpy.degrees(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'degrees'>
A universal function (ufunc) is a function that operates on ndarrays in an element-by-element fashion. The
degreesmethod is a universal function.
Parameters
The degrees function accepts the following arguments:
-
x- array-like structure on the contents of thedegreesfunction will be applied. The input array will be in radians. -
out(optional) - the function’s output is stored at this location. -
where(optional) - if set as True, a universal function is calculated at this position. -
casting(optional) - enables the user to decide how the data will be cast. If set as same_kind, safe casting will take place. -
order(optional) - determines the memory layout of the output. For example, if set as K, the function reads data in the order it is written in memory. -
dtype(optional) - the data type of the array. -
subok(optional) - to pass subclasses,subokmust be set as True.
Return value
The degrees function returns the corresponding degree values of type float in a ndarray. If the optional parameter out is provided, it returns a reference.
If x is a scalar, the return value is also a scalar.
Example
The example below demonstrates how to apply the degrees function on an array containing four radian values.
import numpyrad = [1, 1.5, 2*numpy.pi, 2.5]deg = numpy.degrees(rad)print(deg)
Free Resources