# Convert a radian array to degrees in Python

PythonNumpyServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

To convert a radian array to degrees, use the numpy.degrees() method in Python Numpy. The 1st parameter is an input array in radians. The 2nd and 3rd parameters are optional. The 2nd parameter is an ndarray, 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.

The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value.

## Steps

At first, import the required library −

import numpy as np

Create an Array −

arr = np.arange(12.)


Displaying our array −

print("Array...",arr)

Get the datatype −

print("Array datatype...",arr.dtype)


Get the dimensions of the Array −

print("Array Dimensions...",arr.ndim)

Get the number of elements of the Array −

print("Number of elements in the Array...",arr.size)


res = arr*np.pi/6

To convert a radian array to degrees, use the numpy.degrees() method in Python Numpy. The 1st parameter is an input array in radians −

print("Radian array to degrees...",np.degrees(res))


## Example

import numpy as np

# Create an Array
arr = np.arange(12.)

# Display the array
print("Array...", arr)

# Get the type of the array
print("Our Array type...", arr.dtype)

# Get the dimensions of the Array
print("Our Array Dimensions...",arr.ndim)

# Get the number of elements in the Array
print("Number of elements...", arr.size)

res = arr*np.pi/6

# To convert a radian array to degrees, use the numpy.degrees() method in Python Numpy
print("Radian array to degrees...",np.degrees(res))

## Output

Array...
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.]

Our Array type...
float64

Our Array Dimensions...
1

Number of elements...
12

[ 0. 30. 60. 90. 120. 150. 180. 210. 240. 270. 300. 330.]