Thursday, January 22, 2026
HomeLanguagesConvert angles from radians to degrees in a NumPy array

Convert angles from radians to degrees in a NumPy array

In this article, we will discuss how to convert array elements consisting of different angles as radian to degree.

To convert an angle from radians to degrees we need to simply multiply the radians by 180°/Π?. We can also use the numpy.rad2deg() method to perform the same operation.

Now suppose we have an array containing angles in radian now our task is to convert that array into elements containing element in degree.
Example :

Input : [Π, Π/4, Π/2, 3Π/2, 2Π)
Output : [180.  45.  90. 270. 360.]

Now let us try to implement this using Python:

Example 1 : We will be using the numpy.pi attribute for Π.




# importing the module
import numpy as np
  
# creating an array containing angles in radians
rad = np.array([np.pi, np.pi / 4,
                np.pi / 2, 3 * np.pi / 2,
                2 * np.pi])
print("The angles in radian")
print(rad)
  
# converting array from radian to degree
deg = np.rad2deg(rad)
print("\nThe angles in degree")
print(deg)


Output :

The angles in radian
[3.14159265 0.78539816 1.57079633 4.71238898 6.28318531]

The angles in degree
[180.  45.  90. 270. 360.]

Example 2 : This time the conversion will be performed without using the inbuilt method.




# importing the module
import numpy as np
  
# creating an array containing angles in radians
rad = np.array([3.14159265, 0.78539816,
                1.57079633, 4.71238898,
                6.28318531])
print("The angles in radian")
print(rad)
  
# converting array from radian to degree
deg = []
for angle in rad:
    deg.append(round(angle * (180 / np.pi)))
print("\nThe angles in degree")
print(deg)


Output :

The angles in radian
[3.14159265 0.78539816 1.57079633 4.71238898 6.28318531]

The angles in degree
[180.0, 45.0, 90.0, 270.0, 360.0]
Last Updated :
19 Aug, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS