
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Radian Array to Degrees in Python
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...\n",arr)
Get the datatype −
print("\nArray datatype...\n",arr.dtype)
Get the dimensions of the Array −
print("\nArray Dimensions...\n",arr.ndim)
Get the number of elements of the Array −
print("\nNumber of elements in the Array...\n",arr.size)
Radian array −
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("\nRadian array to degrees...\n",np.degrees(res))
Example
import numpy as np # Create an Array arr = np.arange(12.) # Display the array print("Array...\n", arr) # Get the type of the array print("\nOur Array type...\n", arr.dtype) # Get the dimensions of the Array print("\nOur Array Dimensions...\n",arr.ndim) # Get the number of elements in the Array print("\nNumber of elements...\n", arr.size) # Radian array res = arr*np.pi/6 # To convert a radian array to degrees, use the numpy.degrees() method in Python Numpy print("\nRadian array to degrees...\n",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 Radian array to degrees... [ 0. 30. 60. 90. 120. 150. 180. 210. 240. 270. 300. 330.]